vue缓存页码数

201 阅读1分钟

state

listPagePars: new Map()

mutations

SAVE_LIST_PAGE_PARS: (state,{ path,pars }) => {
  console.log('state vuex ==',pars)
  state.listPagePars.set(path,pars);
},

actions

saveListPagePars: ({ commit },{path,pars}) => {
  commit('SAVE_LIST_PAGE_PARS',{ path,pars });
},

this.$store.dispatch('saveListPagePars',{path:this.$route.path+'_1',pars:aaa});

let currentPage1 = this.$store.state.listPagePars.has(this.$route.path+'_1')?this.$store.state.listPagePars.get(this.$route.path+'_1'):1