路由守卫
This commit is contained in:
parent
40ded001f8
commit
7f9bcd7000
|
@ -22,5 +22,14 @@ const routes = [
|
||||||
const router = new VueRouter({
|
const router = new VueRouter({
|
||||||
routes
|
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
|
export default router
|
||||||
|
|
Loading…
Reference in New Issue
Block a user