问题描述
使用
<Select
native
value={item.resolution}
onChange={this.handleChange}
inputProps={{
name: 'student',id: 'student',data_id: index
}}
>
{ this.state.students ? this.state.students.map((res,i) => (
<option key={index+i} value={res.id}>{res.name}</option>
)): ''}
</Select>
在构造函数中
constructor(props) {
super(props);
this.state = {
students: []
}
}
componentDidMount() {
this.getOptions()
}
async getOptions(){
const res = await axios.get('https://jsonplaceholder.typicode.com/users')
const data = res.data
const options = data.map(d => ({
"value" : d.id,"label" : d.name
}))
this.setState({students: options})
}
一切正常,但已选择显示如下
如何解决?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)