其他分享
首页 > 其他分享> > vuex 刷新保存数据

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);
      });
    },

标签:stringify,vuex,JSON,保存,state,localStorage,刷新,beforeunload,store
来源: https://www.cnblogs.com/tutao1995/p/11641329.html