vue知识点总结 --- vuex热更替

  • 修改state、mutations等配置时,不触发页面刷新
    export default () => {
      const store = new Vuex.Store({
        state: defaultState,
        mutations,
        actions,
        getters
      })
      // webpack热更替
      if (module.hot) {
        module.hot.accept([
          './state/state',
          './mutations/mutations',
          './actions/actions',
          './getters/getters'
        ], () => {
          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
    }

     

你可能感兴趣的:(vue)