码迷,mamicode.com
首页 > 其他好文 > 详细

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.)

时间:2021-06-06 19:32:40      阅读:0      评论:0      收藏:0      [点我收藏+]

标签:navig   修改   from   tac   red   break   ror   log   product   

出现错误

提示信息:技术图片

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

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.)

标签:navig   修改   from   tac   red   break   ror   log   product   

原文地址:https://www.cnblogs.com/lceihen/p/14855144.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!