突然发现子路由path写不写‘/’是有差别的
1. 路径不写 ’ / '
{
path: '/home',
component: Home,
children: [
{
path: '',
redirect: 'welcome'
},
{
path: 'welcome',
component: Welcome
}
]
}
浏览器中路径显示:
跳转welcome页面方法:
this.$router.push('/home/welcome')
2. 路径写 ’ / '
{
path: '/home',
component: Home,
children: [
{
path: '/',
redirect: '/welcome'
},
{
path: '/welcome',
component: Welcome
}
]
}
浏览器中路径显示:
跳转welcome页面方法:
this.$router.push('/welcome')