// mutation-types.js
export const SOME_MUTATION = 'SOME_MUTATION'
// store.js
import Vuex from 'vuex'
import { SOME_MUTATION } from './mutation-types'
const store = new Vuex.Store({
state: { ... },
mutations: {
[SOME_MUTATION] (state) {
// mutate state
}
}
})
store中的mutations的“[SOME_MUTATION]” 这种写法是啥意思,怎么理解呢?为啥要加个中括号?
这是es6的写法,转换为es5时这样的
参考:ECMAScript 6 入门-对象的扩展