0
我有我的路由工作正常,使用導航衛士,以便用戶無法訪問登錄或登錄路由一旦登錄。 。但是,當我在地址欄/auth/signin
中輸入時,登錄屏幕在重定向到儀表板之前不久出現(因爲它在beforeEach
中檢測到該路線是requiresGuest)。問題與Vue.js,顯示登錄屏幕不久,當用戶認證(全頁面刷新)
router.beforeEach(function (to, from, next) {
// prevent access to login & register after signing in
if (to.matched.some(record => record.meta.requiresGuest)
&& auth.user.authenticated)
{
next({
path: '/dashboard'
});
}
if (to.matched.some(record => record.meta.requiresAuth)) {
// this route requires auth, check if logged in
// if not, redirect to login page.
if (!auth.user.authenticated) {
next({
path: '/auth/signin',
query: { redirect: to.fullPath }
})
}
}
next() // make sure to always call next()!
});
有沒有一種方法,以防止組件從閃存出現這樣的!? 組件創建之前是不是觸發beforeEach
?
不,它和以前一樣 – branquito