From 7f9bcd7000e4373b49e06568fb05ca3dd08693b2 Mon Sep 17 00:00:00 2001 From: xing Date: Tue, 16 Jun 2020 15:28:53 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B7=AF=E7=94=B1=E5=AE=88=E5=8D=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/router/index.js b/src/router/index.js index dff2277..edf2ec3 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -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