举例说明:
当路由组件Home.vue嵌套子路由Welcome.vue,同时需要将父路由重定向到子路由时
若子路由的path写为 ’/welcome‘ ,父路由重定向应为 redirect:'/welcome'
routes: [
{
path: '/home',
component: Home,
redirect: '/welcome',
children: [{ path: '/welcome', component: Welcome }]
},
],
})
若子路由的path写为 'welcome' ,父路由重定向应为 redirect:'/home/welcome' 否则无法达到预期效果
routes: [
{
path: '/home',
component: Home,
redirect: '/home/welcome',
children: [{ path: 'welcome', component: Welcome }]
},
],
})