router/index.js导入Vue和路由插件VueRouter导入自定义组件importVuefrom'vue'importVueRouterfrom'vue-router'constHome=()=>import('../home/Home')constProfile=()=>import('../profile/Profile')1.安装插件Vue.use(VueRouter)2.创建路由对象constroutes=[{path:'',redirect:'/home'},{path:'/home',component:Home},{path:'/home',component:Home}]constrouter=newVueRoute({routes})3.导出路由导出默认routerApp.vue1.导入新Vue({el:'#app',router,render:h=>h(App)})
