Source code learning in the Vuex project Example (2)

counter-hot

project description

insert image description here

The functional difference from the first item is that the last five operations will be recorded. From the name of the project, we know it's about hot reloading.

Improvements on the project

Compared with the first project, the improvement is to split the store.js in the first project into multiple js. Split mutations, actions, and getters into different js. You can learn to split the configuration of vuex through this project.

About Hot Update

if (module.hot) {
    
    
  module.hot.accept([
    './getters',
    './actions',
    './mutations'
  ], () => {
    
    
    store.hotUpdate({
    
    
      getters: require('./getters'),
      actions: require('./actions'),
      mutations: require('./mutations')
    })
  })
}

Knowledge points that can be learned

  1. Learn to split vuex
  2. Code when introducing multiple objects
  3. Learn to hot reload. Personally feel that if necessary, just check the documentation.
import * as getters from './getters'
import * as actions from './actions'
import * as mutations from './mutations'

Guess you like

Origin blog.csdn.net/aofengdaxia/article/details/114580567