vuex 刷新保存数据

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);
      });
    },
posted @ 2019-10-09 13:48  Tutao1995  阅读(503)  评论(0编辑  收藏  举报