1234567891011121314151617181920212223242526272829303132 |
- /*
- * @Author: 廖明明
- * @Date: 2022-03-31 16:36:19
- * @LastEditors: 廖明明
- * @LastEditTime: 2022-04-01 17:45:03
- * @Description:vuex入口文件
- */
- import Vue from "vue";
- import Vuex from "vuex";
- import user from "@/store/modules/user";
- Vue.use(Vuex);
- const myPlugin = (store) => {
- // 当 store 初始化后调用
- let vuexStorage = uni.getStorageSync("vuexStorage");
- if (vuexStorage) {
- store.replaceState(vuexStorage);
- }
- store.subscribe((mutation, state) => {
- uni.setStorageSync("vuexStorage", state);
- });
- };
- export default new Vuex.Store({
- modules: {
- user,
- },
- plugins: [myPlugin],
- });
|