要从数组中删除元素,只需执行以下操作:
array.splice(index, 1);
在您的情况下:
removePeople(e) { var array = [...this.state.people]; // make a separate copy of the array var index = array.indexOf(e.target.value) if (index !== -1) { array.splice(index, 1); this.setState({people: array}); }},


