【发布时间】:2019-09-23 08:02:04
【问题描述】:
我有一个国家列表,我可以得到ID国家列表,如何获得国家名称?
我的状态
this.state = {
MEMBER_COUNTRY_ID:'',
MEMBER_COUNTRY_NAME:''
}
这个 html 选择
<Form.Group controlId="countryList">
<Form.Label><b>Country</b></Form.Label>
<Form.Control as="select" ref="idCountry" onClick={this.handleSelect}>
{dataCountry}
</Form.Control>
</Form.Group>
const dataCountry = this.state.country.map(countryList=> {
return(
<option key={countryList.country_id} value={countryList.country_id}>
{countryList.country_name} //how to get country name?
</option>
)
})
这是我的活动
handleSelect(){
if (this.refs.idCountry) {
this.setState({
MEMBER_COUNTRY_ID:this.refs.idCountry.value.
MEMBER_COUNTRY_NAME:
})
}
}
【问题讨论】:
标签: javascript reactjs select