created () {
// 阻止刷新vuex丢失
if (localStorage.getItem('store')) {
this.$store.replaceState(Object.assign({}, this.$store.state, JSON.parse(localStorage.getItem('store') || '{}')));
localStorage.removeItem('store');
}
window.addEventListener('beforeunload', () => {
localStorage.setItem('store', JSON.stringify(this.$store.state));
});
}
网友评论