页面刷新保存当前页面数据
vue 中 和vuex结合//在页面加载时读取sessionStorage里的状态信息将字符串转成对象或是数组if (sessionStorage.getItem("store") ) {this.$store.replaceState(Object.assign({}, this.$store.state,JSON.parse(sessionStorage...
·
vue 中 和vuex结合
//在页面加载时读取sessionStorage里的状态信息 将字符串转成对象或是数组
if (sessionStorage.getItem("store") ) {
this.$store.replaceState(Object.assign({}, this.$store.state,JSON.parse(sessionStorage.getItem("store"))))
}
//在页面刷新时将vuex里的信息保存到sessionStorage里 将对象数组转成字符串
window.addEventListener("beforeunload",()=>{
sessionStorage.setItem("store",JSON.stringify(this.$store.state))
})
vue 数据层级太深 监听不到数据,dom不变化进行强制刷新
that.$forceUpdate();
更多推荐
已为社区贡献8条内容
所有评论(0)