
配置路由流程
1、用命令安装路由组件
$ cnpm install vue-router --save
2、main.js中引入并使用如下
import Vue from 'vue'
import VueRouter from 'vue-router'
import App from './App'
Vue.use(VueRouter);
import Index from './components/index/index'
const router = new VueRouter({
routes: [{
path: '/',
component: Index
}]
});
const app = new Vue({
router,
render: h => h(App)
}).$mount('#app')
以上配置了一个index页面。
3、在页面中使用路由

网友评论