index.js 571 B

12345678910111213141516171819202122
  1. import Vue from 'vue'
  2. import Vuex from 'vuex'
  3. import user from '@/store/modules/user'
  4. import getters from './getters'
  5. import createPersistedState from 'vuex-persistedstate' // 引入数据持久化插件
  6. Vue.use(Vuex)
  7. const store = new Vuex.Store({
  8. plugins: [createPersistedState({
  9. storage: {
  10. getItem: key => uni.getStorageSync(key),
  11. setItem: (key, value) => uni.setStorageSync(key, value),
  12. removeItem: key => uni.removeStorageSync(key)
  13. }
  14. })],
  15. modules: {
  16. user
  17. },
  18. getters
  19. })
  20. export default store