import {INCREMENT} from "./types" const mutations = { [INCREMENT] (state) { state.count++; } }
[INCREMENT] Can't INCREMENT be used directly as a variable? Why do we need to add a bracket?
[INCREMENT]
拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...
[INCREMENT]是计算INCREMENT这个变量的值作为函数名,不使用中括号是把INCREMENTThis string is used as the function name.
INCREMENT
const INCREMENT = 'myfunc'; const mutations = { [INCREMENT] (state) { state.count++; } }
Equivalent to the above code, the result is
const mutations = { myfunc(state) { state.count++; } }
And
const INCREMENT = 'myfunc'; const mutations = { INCREMENT (state) { state.count++; } }
is
const mutations = { INCREMENT(state) { state.count++; } }
These are computed property names
https://developer.mozilla.org...
[INCREMENT]
是计算INCREMENT
这个变量的值作为函数名,不使用中括号是把INCREMENT
This string is used as the function name.Equivalent to the above code, the result is
And
The result ofis
These are computed property names
https://developer.mozilla.org...