路由守卫

This commit is contained in:
xing 2020-06-16 15:28:53 +08:00
parent 40ded001f8
commit 7f9bcd7000

View File

@ -22,5 +22,14 @@ const routes = [
const router = new VueRouter({
routes
})
router.beforeEach((to, from, next) => {
if (to.path === '/login') {
return next()
}
const token = sessionStorage.getItem('token')
if (!token) {
return next('/login')
}
next()
})
export default router