I'm trying to create select box dynamically from api response in react.(我试图从反应中的api响应动态创建选择框。)
below is the api response(以下是api响应)
{
"land": [{
"land_id": 15,
"name": "zipku",
"description": "zipku"
}, {
"land_id": 16,
"name": "jumba",
"description": "jumba"
}],
"type": [{
"type_id": 1,
"name": "s_id",
"description": "s_id"
}, {
"type_id": 2,
"name": "s_id2",
"description": "s_id2"
}],
"nationality": [{
"id": 1,
"name": "Japan",
"description": "Japan"
}, {
"id": 2,
"name": "Hong_Kong",
"description": "Hong_Kong"
}]
}
I am using react with ant design.(我正在使用与蚂蚁设计反应。) what I have did so far(到目前为止我所做的)
Object.keys(myObject).map((idx, i) => {
return (<Select key={i}
{...myObject[idx].map((selec, i) => (
<Option value={selec.name}>{selec.name}}</Option>
))}
>
</Select>)
})
Can someone please explain me what I am doing wrong?(有人可以解释一下我在做什么错吗?)
ask by ConAra translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…