如何使vue导航保护在刷新后工作


if(to.matched.some(record =>to.meta.requiresAuth)){
if(store.getters.isAuthenticated == true)
next()
else next({name: "Login"}) 
}
else next()
})

所以,我有这个验证代码。它工作得很好,只是当我刷新页面时,除非我再次登录,否则我无法访问它。如何使它也在刷新时工作?感谢

我想明白了。我使用sessionStorage而不是Vuex存储,因为它即使在刷新后也会保留值。由于某种原因,localStorage无法工作

最新更新