created() {
//在页面加载时读取localStorage里的状态信息
localStorage.getItem(“userMsg”) && this.
s
t
o
r
e
.
r
e
p
l
a
c
e
S
t
a
t
e
(
O
b
j
e
c
t
.
a
s
s
i
g
n
(
t
h
i
s
.
store.replaceState(Object.assign(this.
store.replaceState(Object.assign(this.store.state,JSON.parse(localStorage.getItem(“userMsg”))));
//在页面刷新时将vuex里的信息保存到localStorage里
window.addEventListener("beforeunload",()=>{
localStorage.setItem("userMsg",JSON.stringify(this.$store.state))
})
},
最后
以上就是顺利舞蹈最近收集整理的关于vux 刷新不清除的全部内容,更多相关vux内容请搜索靠谱客的其他文章。
发表评论 取消回复