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

 

posted @ 2017-03-27 21:14  黄鹂  阅读(3220)  评论(0编辑  收藏  举报