猿问

Antd 选择值标签

我的状态只有 id 才能加载选择


//ComponentDidMount method

let countries_data = await axios.get('/api/v1/countries/');

countries_data.data.map((data) => {

  countries.push(<Option key={data.id}>{data.name}</Option>);

});

//My Options are a Option Component


//Render method

<Select 

 showSearch

 placeholder={'Country'}

 size={"large"}

 value={this.state.country_id} //Should show the text from option selected

 onChange={this.onChangeCountry}

 filterOption={(input, option) =>

     option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0}>

     {countries}

 </Select>

这里的主要问题是我用一个整数设置 value 选项,Select 将显示数字,如 27、40,但没有来自选项的国家标签,如国家 A、国家 B 等。我的问题是如何设置值将值设置为整数并向我显示从我的国家/地区数组中选择的选项?


牧羊人nacy
浏览 188回答 2
2回答
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答