方法名定义成常量的写法
经常在项目中遇到这样的写法:
[SOME_MUTATION] (state) {
// mutate state
}
在es6中字面量定义对象时,用表达式作为对象的属性名,把表达式放在方括号内
const SOME_MUTATION = 'SOME_MUTATION'
var mutations = {}
mutations[SOME_MUTATION] = function (state) {
// mutate state
}
//相当于对象的属性打点调用和中括号调用