【发布时间】:2019-01-25 12:46:21
【问题描述】:
当尝试从 React 应用程序中的函数/方法调用返回包含对象的对象时,我得到:
Syntax error: this is a reserved word
导致这个错误的代码是:
const object = {
this.methodOne(),
this.methodTwo(),
this.methodThree()
};
我想将对象返回到一个对象中,但语法错误似乎没有识别出我正在尝试调用这些函数来创建对象,例如:
methodOne(){
return {foo: "bar"}
}
与我的班级分开的函数也会出现同样的问题。
【问题讨论】:
标签: javascript reactjs ecmascript-6 es6-class