这里的问题来自数组中的对象。
react-select需要具有以下键的对象数组才能理解它:
value和
label。
因此,在渲染中,您可以替换
let options = this.state.cities.map(function (city) { return city.name;})通过,例如
let options = this.state.cities.map(function (city) { return { value: city.countryCode, label: city.name };})或者,就像pritesh指出的那样,只需告诉
react-select要使用什么键
render () { return ( <div> <Select name="form-field-name" value={this.state.value} onChange={this.handleChange} clearable={this.state.clearable} searchable={this.state.searchable} labelKey='name' valueKey='countryCode' options={this.state.cities} /> </div> )}希望这可以帮助你!



