vue-router中导航守卫中next 无法访问当前子路由
vue-router代码
{
path: '/admin',
component: Ladmin,
meta:{auth:true},
children: [
{
path: '',
component: Admin,
},
{
path: 'login',
component: Login,
},
]
},
导航守卫代码
router.beforeEach((to, from, next) => {
if(to.matched.some( m => m.meta.auth)){
if(store.state.isLogin == true){
next()
}else{
next('/admin/login')
}
}else{
next()
}
})
最后这样却可以了
{
path: '/admin',
component: Ladmin,
meta:{auth:true},
children: [
{
path: '',
component: Admin,
},
]
},
{
path: '/admin/login',
component: Login,
}
这到底怎么回事 为什么啊 求解答
beforeEach必须要执行了next()才会执行下面的代码,你设置导航路由钩子时那个store.state.isLogin是为true吗