2.4 Vuex最佳实践
一、核心概念补充
二、使用常量代替Mutation事件类型
// mutation-types.js
export const SOME_MUTATION = 'SOME_MUTATION'
// stors.js
import Vuex from 'vuex'
import {SOME_MUTATION} from './mutation-types'
const store = new Vuex.Store({
state: {...},
mutations: {
[SOME_MUTATION] (state) {
// mutate state
}
}
})三、Module(命名空间)
Last updated