From 354d0d79625de1e75e7280bcf7c03f9709009d23 Mon Sep 17 00:00:00 2001 From: Zhu <613366667@qq.com> Date: Mon, 19 Nov 2018 22:58:24 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=B0=83=E7=94=A8next(...)=E9=87=8D?= =?UTF-8?q?=E5=AE=9A=E5=90=91=E4=B8=8D=E4=BC=9A=E8=A7=A6=E5=8F=91router.af?= =?UTF-8?q?terEach=E9=92=A9=E5=AD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在未登录状态下,在地址栏输入需要登录后才能访问的页面url,应用会重定向至login。但是这时顶部的 NProgress 依然在加载中,因为`next(...)`重定向不会触发`router.afterEach`钩子,这里需要手动hack一下。 Former-commit-id: 1fa31ccca534e54a920451320c971eaf4b771417 --- src/router/index.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/router/index.js b/src/router/index.js index 4cf7d27..6cd423d 100755 --- a/src/router/index.js +++ b/src/router/index.js @@ -43,6 +43,7 @@ router.beforeEach((to, from, next) => { next({ name: 'login' }) + NProgress.done() // next(...)重定向不会触发router.afterEach钩子,需要手动hack一下 } } else { // 不需要身份校验 直接通过