vue 登錄路由判斷


 

 1  router.beforeEach((to, from, next) => {
 2   // alert(sessionStorage.getItem('accessToken'))
 3   //    console.log(to);
 4      if ((to.path!='/login')&&(!sessionStorage.getItem('accessToken') || sessionStorage.getItem('accessToken')=='undefined')) {
 5          next({
 6              path: '/login',
 7              // query: { redirect: to.fullPath }
 8          })
 9      } else {
10          next()
11      }
12  })

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM