vue写后台管理的时候登陆验证

router.beforeEach((to, from, next) => {
  if(to.path === '/'){
    next()
  }
  else{
    if(to.meta.requiresAuth && !sessionStorage.getItem('iphone')){
      next({
        path: '/'
      })
    }
    else{
      next()
    }
  }
})

感觉他写的比较详细,防止忘记

猜你喜欢

转载自blog.csdn.net/qq_42809973/article/details/84653343