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