如何在反应中访问编号状态

How to access numbered state in rect

是访问编号状态的任何方法。例如

this.setState({123:hello})

现在我怎样才能访问这个状态

console.log(this.state.123)  //this will show error

您可以执行以下操作:

this.state[123]

但是您不应该使用数字作为对象 属性 名称。