我的构造函数中有一个状态数组:
constructor(props) {
super(props);
this.state = {myarray: []};
}
Run Code Online (Sandbox Code Playgroud)
现在我想在特定的下标更新数组.
this.setState({myarray[i]: 'test'});
Run Code Online (Sandbox Code Playgroud)
给我一个unexpected token错误,指着开口括号[
这样做的正确方法是什么?
PS数组使用push方法动态填充,然后我尝试更新
reactjs ×1