vuex:
const state = {
state: {
token: sessionStorage.getItem('token') || '',
},
}
router:
router.beforeEach(function(to, from, next) {
console.log(to.meta.auth,store.state.token,to.path);
if (to.meta.auth && !store.state.token && to.path !== '/login') {
return next({
path: '/login',
query: {redirect: to.fullPath}
})
}
next();
});
在用户登陆后刷新页面,为什么beforeEach里store.state.token
为空?
因为我把store写成了state...
QAQ每天都在问傻逼问题