master
luoJunYong.123 3 years ago
parent 9b7efcb5af
commit 423dd6aac7
  1. 6
      src/App.vue

@ -12,11 +12,11 @@
export default { export default {
created () { created () {
//localStorage //localStorage
localStorage.getItem("userMsg") && this.$store.replaceState(Object.assign(this.$store.state,JSON.parse(localStorage.getItem("userMsg")))); sessionStorage.getItem("userMsg") && this.$store.replaceState(Object.assign(this.$store.state,JSON.parse(sessionStorage.getItem("userMsg"))));
//vuexlocalStorage //vuexsessionStorage
window.addEventListener("beforeunload",()=>{ window.addEventListener("beforeunload",()=>{
localStorage.setItem("userMsg",JSON.stringify(this.$store.state)) sessionStorage.setItem("userMsg",JSON.stringify(this.$store.state))
}) })
} }
} }

Loading…
Cancel
Save