【发布时间】:2018-06-30 06:00:33
【问题描述】:
在这里,我在App 类中创建了一个局部变量persons,然后根据某些条件为其分配一个JSX,然后在render() 方法中传递它({persons})。
let persons = null;
if (this.state.showPerson) {
persons = (
<div>
<RenderPerson
name={this.state.customers[0].name}
age={this.state.customers[0].age} />
<RenderPerson
name={this.state.agents[1].name}
age={this.state.agents[1].age} />
</div>
);
}
let showPersons = null; 出现编译错误。在 VS 代码中,如果我将鼠标悬停在 let 关键字的红色标记行上,它会显示:[js] Unexpected token. A constructor, method, accessor, or property was expected.
【问题讨论】:
标签: reactjs ecmascript-6