思路是页面关闭前将state
的数据存储到浏览器缓存里,页面加载时再取出来存到state
中
//App.vue
created () {
if (this.$getLocal("store")) {
this.$store.replaceState(
Object.assign({}, this.$store.state, this.$getLocal("store", "parse"))
);
}
window.addEventListener("beforeunload", () => {
this.$setLocal("store", this.$store.state);
});
}
原文地址:https://www.cnblogs.com/ak-b/p/10525471.html
时间: 2024-11-07 12:55:30