失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > vue3 router.beforeEach 全局路由守卫 白屏问题 以及报错路由无效

vue3 router.beforeEach 全局路由守卫 白屏问题 以及报错路由无效

时间:2018-11-06 23:24:16

相关推荐

vue3 router.beforeEach 全局路由守卫 白屏问题 以及报错路由无效

如果是使用ts跟vue3的话,要注意的官方文档的写法,不然会报错

正确的写法是:

router.beforeEach((to, from, next) => {if (window.sessionStorage.getItem('token')) {if (to.name == '/') next({ path: '/home/driveradmin' })else next()} else {next()}})

如果觉得《vue3 router.beforeEach 全局路由守卫 白屏问题 以及报错路由无效》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。