Vuex prevents data loss after refresh

VuexAlong will be used here, please download vuexAlong to the project first

npm install vuexAlong -S

store.js

//引入vuex-along
import VueXAlong from 'vuex-along'

const store = new Vuex.Store({
    
    
  state: {
    
    
//业务代码
  },
  mutations: {
    
    
   //业务代码
    },
 plugins: [VueXAlong({
    
    
    name: 'my-along',     // 存放在localStroage或者sessionStroage 中的名字
    local: true,      // 是否存放在local中  false 不存放 如果存放按照下面session的配置配
    session: {
    
     list: [], isFilter: true } // 如果值不为false 那么可以传递对象 其中 当isFilter设置为true时, list 数组中的值就会被过滤调,这些值不会存放在seesion或者local中
  })],
});

Guess you like

Origin blog.csdn.net/weixin_38987500/article/details/106854968