ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
``` import Vuex from 'vuex'; import defaultState from './state/state.js'; import mutations from './mutations/mutations.js'; import getters from './getters/getters'; import actions from './actions/actions' const isDev = process.env.NODE_ENV === 'development'; export default () => { //让webpack支持对store的热替换 const store = new Vuex.Store({ strict: isDev, state: defaultState , mutations , getters , actions }); if(module.hot){ module.hot.accept([ './state/state' ,'./mutations/mutations' ,'./actions/actions' ,'./getters/getters' ],()=>{ //因为是export default导出的(是es6语法) 故需要require().default 引入 const newState = require('./state/state').default; const newMutations = require('./mutations/mutations').default; const newActions = require('./actions/actions').default; const newGetters = require('./getters/getters').default; store.hotUpdate({ state:newState ,mutations:newMutations ,actions:newActions ,getters:newGetters }) }); } return store; }; ```