[toc]
```
import Vue from 'vue'
import Router from 'vue-router'
import Home from './pages/home/Home.vue';
import City from './pages/city/City.vue';
import Detail from './pages/detail/Detail.vue';
Vue.use(Router);
export default new Router({
routes: [
{
path: '/'
, name: 'Home'
, component: Home
}
,{
path: '/city'
, name: 'City'
, component: City
}
,{
path: '/detail/:id'
, name: 'Detail'
, component: Detail
}
]
//每次進入頁面時都初始化滾軸位置
,scrollBehavior(to,from,savedPosition){
return {x: 0, y: 0};
}
})
```
然后注入進根實例
```
new Vue({
router
, store
, render: h => h(App)
}).$mount('#app');
```
- 空白目錄
- vue-cli
- runtime-only
- Vue對比React
- 組件與實例
- data-binding
- computed的set和get
- scoped
- 事件
- 自定義指令
- 插件
- keep-alive
- $nextTick與生命周期
- 路由
- Vue.use(Router)
- this.$router編程式導航
- this.$route
- new Router
- routes
- mode
- linkClass
- scrollBehavior
- query
- fallback
- base
- router-view
- router-link
- 路由守衛
- 左右切換
- 滾動
- FAQ
- vuex
- 適用
- new Vuex.Store
- state
- mutations
- getters
- actions
- strict
- plugins
- modules
- namespace
- this.$store
- commit
- dispatch
- mapXX
- eventBus
- Vue工程相關
- 引用路徑的簡化
- css-module
- vue-loader
- 異步加載
- 支持jsx
- 讓webpack支持對vuex的熱替換
- .eslintrc