import Vue from "vue";
import Vuex from "vuex";
import createPersistedState from "vuex-persistedstate";
// npm install --save vuex-persistedstate
Vue.use(Vuex);
import user from "./api/user";
export default new Vuex.Store({
plugins: [
createPersistedState({
storage: {
getItem: key => uni.getStorageSync(key),
setItem: (key, value) => uni.setStorageSync(key, value),
removeItem: key => uni.removeStorageSync(key)
},
paths: ['user'] //打包后
// paths: ['user'] //本地调试
})
],
modules: {
user
}
});
1 个回复
阿狸的祈祷 (作者)
真相只有一个,vuex版本太高
yarn add vuex@3.6.2 | npm i vuex@3.6.2
安装后正常