退出登录需要手动刷新
来源:8-11 作业:注册页面的编写
浴室熊
2021-12-22
老师好,我退出登录的时候使用localStorage.removeItem(‘token’),再router.push({ name: ‘home’ }),发现右上角还是显示登录过的状态“你好xxx”,我就手动刷新加了一个location.reload(),有什么好的办法不用手动刷新吗?还是说退出登录只能手动刷新,router跳转没有用
源码地址:https://github.com/ysx-hidden/zheye
写回答
1回答
-
张轩
2021-12-22
同学你好 除了删除 token 还需要将 state 中的 isLogin 设置成 false ,请看我在 develop 中的源代码
https://git.imooc.com/coding-449/zheye/src/develop/src/store.ts#L143
222025-03-03
相似问题
注册登录都全了,还差个退出登录
回答 1
退出登陆
回答 2