在这里,我在类中创建一个局部变量persons
,App
然后JSX
根据某些条件为其分配 a ,然后{persons}
在render()
方法内部传递 it( ) 。
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.