``` import Vue from 'vue' import Vuex from 'vuex' import state from './state' import mutations from './mutations' import actions from './actions' import getters from './getters' // import modulesA from './modulesA'
Vue.use(Vuex)
export default () => { const store = new Vuex.Store({ state, mutations, actions, getters // modules: { // a: modulesA // } })
// 添加热更新,每个Store如果需要热更新都需要添加这段代码 // 里面的路径可以自行根据自己配置修改 if (module.hot) { module.hot.accept([ './state', './mutations', './actions', './getters' // './modulesA' ], () => { const newState = require('./state').default const newMutations = require('./mutations').default const newActions = require('./actions').default const newGetters = require('./getters').default const newModulesA = require('./modulesA').default
store.hotUpdate({ state: newState, mutations: newMutations, actions: newActions, getters: newGetters // modules: { // a: newModulesA // } }) })
}
return store } ```