vue嵌套路由
2019-04-19 本文已影响4人
一条小团团ovo的就很棒
-
嵌套路由
定义:路由中嵌套子路由,子路由中关键属性children
例:
-
页面上
<div>
<router-view></router-view>
<div>
-
路由中
import Vue from "vue";
import VueRouter from "vue-router";
Vue.use(VueRouter);
export default new VueRouter({
mode:"history";
routes:[
{
path:"/",
redirect:"/login"
},{
path:"/home",
component:resolve=>require(["../components/login.vue"]),
children:[
{
path:"/user",
component:resolve=>require(["../component/user.vue"])
}
]
},
{
path:"/login",
component:resolve=>require(["../components/login.vue"])
}
]
})