vuex中mutations常量加中括号的写法解析
作者:互联网
方法名定义成常量的写法
经常在项目中遇到这样的写法:
[SOME_MUTATION] (state) {
// mutate state
}
在es6中字面量定义对象时,用表达式作为对象的属性名,把表达式放在方括号内
const SOME_MUTATION = 'SOME_MUTATION'
var mutations = {}
mutations[SOME_MUTATION] = function (state) {
// mutate state
}
//相当于对象的属性打点调用和中括号调用
标签:mutate,写法,SOME,mutations,state,MUTATION,vuex,中括号 来源: https://www.cnblogs.com/my466879168/p/12236819.html