首页 新闻 赞助 找找看

vue history模式下输入url不会触发路由守卫

0
悬赏园豆:20 [待解决问题]

在vue路由改为history模式时,直接输入url时不会触发路由守卫就直接进入页面的问题

vue
r4847296shaodifu2的主页 r4847296shaodifu2 | 初学一级 | 园豆:17
提问于:2019-06-10 12:25

可以晒一点代码吗?能模拟出问题才好解决问题。

hellotim 4年前

@hellotim: router.beforeEach((to, from, next) => {
if(to.meta.Login === true){
if(getLoginData() === true){
next('/my');
}
}
if(to.meta.needLogin === true){
if(getLoginData() === true){
next();
} else {
next("/personal");
}
} else {
next();
}
});

他不会判断直接就进入了页面

r4847296shaodifu2 4年前
< >
分享
所有回答(1)
0

console.log() 输出一下,看是怎么执行得。

ohyex | 园豆:1496 (小虾三级) | 2019-06-10 22:00

打印了,进入页面没有触发路由守卫

支持(0) 反对(0) r4847296shaodifu2 | 园豆:17 (初学一级) | 2019-06-11 22:01
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册