在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/網(wǎng)絡安全  HTML/ router.beforeEach

router.beforeEach

clipboard.png
clipboard.png

看到好多博客中都說router.beforeEach中在調(diào)用next('/login')后會再次調(diào)用router.beforeEach,但是
!user=true 和 to.path != '/login' 都為 true,執(zhí)行了 next('/login') 后并沒有再次調(diào)用router.beforeEach,而且if條件中執(zhí)行 next('/login') 還是為 true 的,但是我要是把 next('/login') 改為其他路由,就會出現(xiàn)死循環(huán)的調(diào)用,是因為執(zhí)行next('/login')后有什么改變嗎

回答
編輯回答
遺莣

你上面寫的邏輯會死循環(huán)
看了半天感覺就一句話。

let user=xxxxxx
if(!user){
   next({ path: '/login' })
}else{
   next()
}
2017年3月7日 14:56
編輯回答
悶油瓶

先搞清楚你一開始打開的頁面是不是login,如果是login肯定就只只會執(zhí)行一次

2018年4月8日 16:54