问题:从登录页面跳转到首页,页面不会刷新,退出按钮不会出现,需要手动刷新才会出现
解决方法在需要刷新的页面里面添加
const router = useRouter();
router.beforeEach((to, from, next) => {
console.log(to);
if (window.localStorage.getItem("token")) {
state.value = true;
}
next();
return false;
});
路由守卫功能