关于vuex:vuex数据持久化处理

58次阅读

共计 1065 个字符,预计需要花费 3 分钟才能阅读完成。

次要利用插件 vuex-persistedstate

import Vue from "vue";
import Vuex from "vuex";
import storeSidebar from "./storeSidebar";
import storeConsole from "./storeConsole";
import storeLogin from "./storeLogin";
import storeUrl from "./storeUrl";
import storeUserFliters from "./storeUserFliters";
import storeRoleFliters from "./storeRoleFliters";
import storeUser from "./storeUser";
import storeRole from "./storeRole";
import storeWidget from "./storeWidget";
import storeOrgan from "./storeOrgan";
import storeUserImage from "./storeUserImage";
import CreatePersistedState from "vuex-persistedstate";
Vue.use(Vuex);

export default new Vuex.Store({state: {},
  mutations: {},
  actions: {},
  modules: {
    storeSidebar,
    storeConsole,
    storeLogin,
    storeUrl,
    storeUserFliters,
    storeUser,
    storeWidget,
    storeRoleFliters,
    storeRole,
    storeOrgan,
    storeUserImage
  },
  plugins: [
    CreatePersistedState({reducer(val) {
        return {
          assessmentData: val.storeLogin,
          storeSidebar: val.storeSidebar,
          storeUserImage: {userImage: val.storeUserImage.userImage},
          storeUrl: {
            url: val.storeUrl.url,
            MenuList: val.storeUrl.MenuList,
            RelationList: val.storeUrl.RelationList,
            appList: val.storeUrl.appList
          }
        };
      }
    })
  ]
});

正文完
 0