router.beforeEach((to, from, next) => {}做登录页面

router.beforeEach((to, from, next) => {
  if (to.path != '/login') {
    if (!window.sessionStorage.getItem("username")) {
      next({
        path: '/login'
      })
    } else {
      next()
    }
  } else {
    next()
  }
})

你可能感兴趣的:(router.beforeEach((to, from, next) => {}做登录页面)