vue之路由嵌套

我们在做项目的时,常常会遇到使用Tab切换页面需求,要求设置第一个选项卡为默认选项。这时候我们就需要用到 vue-router 嵌套路由实现。设置默认项使用 redirect 属性即可。

export default new Router({
routes: [
{
path: '/',
name: 'page',
component: Page,
redirect:'/tab1', // 设置默认打开的页面
children: [{
path: '/tab1',
name: 'tab1',
component: tab1,
},
{
path: '/tab2',
name: 'tab2',
component: tab2,
}

{
path: '/tab3',
name: 'tab3',
component: tab3,
}]

}
]
})

原文地址:https://www.cnblogs.com/whx123/p/12101084.html