Skip to content

Latest commit

 

History

History
47 lines (27 loc) · 921 Bytes

vue-router-learn.md

File metadata and controls

47 lines (27 loc) · 921 Bytes

vue-router 原文文档 for Vue.js 2 (尤雨溪大神)

1. 安装 (环境要求为 vue-cli )

npm install vue-router

如果在一个模块化工程中使用它,必须要通过 Vue.use() 明确地安装路由功能:

import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

2. 如果要把 vue-router 纳入 vuex 的 state 中使用

# for vuex & vue-router >= 2.0:
npm install vuex-router-sync@next
import { sync } from 'vuex-router-sync'
import store from './vuex/store' // vuex store instance
import router from './router' // vue-router instance

sync(store, router) // done.

// bootstrap your app...