vue验证登录(Detected an infinite redirection in a navigation guard when going from "/" to "/login". Aborting to avoid a Stack Overflow. This will break in production if not fixed.)
出现错误
提示信息:
router.beforeEach((to, from, next) => {
if (!storage.getItem('userInfo')) {
console.log('error')
next({ path: '/login' })
} else {
console.log('ok')
next()
}
})
修改bug后
router.beforeEach((to, from, next) => {
if (to.path === '/login') next()
if (!storage.getItem('userInfo')) {
next({ path: '/login' })
} else {
console.log('ok')
next()
}
})

浙公网安备 33010602011771号