vue router2.0二级路由的简单使用
本文实例为大家分享了vuerouter2.0二级路由的具体代码,供大家参考,具体内容如下
1、app.vue中
2、router中index.js(路由的路径配置)
importVuefrom'vue' importRouterfrom'vue-router' importHellofrom'@/components/Hello' importLoginfrom'@/components/Login' importindexfrom'@/components/index' importHeaderfrom'@/components/Header/Header' importProductfrom'@/components/Product/Product' Vue.use(Router) exportdefaultnewRouter({ routes:[ { path:'/', name:'Login', component:Login }, { path:'/index', name:'index', component:index, children:[//这里就是二级路由的配置 { path:'/hello', name:'Hello', component:Hello }, { path:'/header', name:'Header', component:Header }, { path:'/product', name:'Product', component:Product } ] } ] })
3、下面是我们的index.vue中的代码
Gotohello Gotoheader Gotoproduct