1. 导入路由组件
npm install vue-router --save
2.配置路由
- 在router文件夹中创建index.js文件
`import Vue from 'vue';
import VueRouter from 'vue-router';
Vue.use(VueRouter);
const Index = ()`=>import ('views/tab-item/index/Index.vue');//设置别名
const Notice = ()=>import ('views/tab-item/notice/Notice')
const routes =[
{path:'/',redirect:'/index'},
{path:'/index',component:Index},
{path:'/notice'component:Notice}
]
const router = new VueRouter({
mode:history,//设置history模式
routes
})