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()
    }
})


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM