标签:保存 存在 tor 路由 == log for route pre
1 // 路由守卫 2 router.beforeEach((to, from, next) => { 3 //获取用户登录成功后储存在本地的token 4 let token = localStorage.getItem("token") 5 // 如果token存在,即用户已经登录过 6 if (token) { 7 if (to.meta.requireAuth) { 8 next() 9 } else { 10 next({ path: ‘/home‘ }) 11 } 12 } else { 13 if (to.path === ‘/home‘) { 14 next({ path: ‘/login‘ }) 15 } else { 16 next() 17 } 18 } 19 })
标签:保存 存在 tor 路由 == log for route pre
原文地址:https://www.cnblogs.com/rrrjc/p/11729635.html