老街一角 2022-01-11 11:15 采纳率: 68.8%
浏览 51

路由守卫出现无限循环的问题怎么解决


router.beforeEach((to, from, next) => {
  // console.log(to.matched)
  console.log(to.path)
  if(utils.getCookie('sub_phone')) {
    // return next()
    console.log(store.state.vip_level)
    if(['vip','normal','readonly'].indexOf(store.state.vip_level) != -1) {
      console.log('aa')
      next()
    }else if(store.state.vip_level == null) {
      console.log('bb')
      next('/user')
    }
  }else {
    if(to.path === '/login') {
      next()
    }else {
      next('/login')
    }
  }
})
  • 写回答

1条回答 默认 最新

  • づGeranium☆う 2022-01-11 14:31
    关注

    .......................

    评论

报告相同问题?

问题事件

  • 修改了问题 1月11日
  • 创建了问题 1月11日