created () {
      this.$store.replaceState(Object.assign(this.$store.state,JSON.parse(localStorage.getItem("beforeunload"))));
      window.addEventListener('beforeunload', ()=>{
        let state = JSON.stringify(this.$store.state)
          localStorage.setItem("beforeunload",state);
      });
    },

在created 生命周期中 保存数据 和同步数据

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2021-08-21
  • 2022-01-15
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-16
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-07-13
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案