修改state, mutations, getters 等配置时,不触发页面刷新
store.js
import Vuex from 'vuex'
import defaultState from './state/state'
import mutations from './mutations/mutations'
import getters from './getters/getters'
import actions from './actions/actions'
export default () => {
const store = new Vuex.Store({
strict: true, //禁止在非mutations内修改data的数据
state: defaultState,
mutations,
getters,
actions
})
if (module.hot) {
module.hot.accept([
'./state/state',
'./mutations/mutations',
'./getters/getters',
'./actions/actions'
], () => {
const newState = require('./state/state').default
const newMutations = require('./mutations/mutations').default
const newGetters = require('./getters/getters').default
const newActions = require('./actions/actions').default
store.hotUpdate({
store: newState,
mutations: newMutations,
getters: newGetters,
actions: newActions
})
})
}
return store
}
来源:CSDN
作者:阿狸小师妹
链接:https://blog.csdn.net/mwn_cookie/article/details/104755748