【发布时间】:2018-06-20 12:13:59
【问题描述】:
我现在有这样的下拉菜单。它的工作我得到了我需要的值,但是当值是一个对象时,如何在下拉列表中更改名称。请问有什么想法吗?
onDropdownSelected = (e) => {
if (e.target.value !== '') {
const inst = JSON.parse(e.target.value)
console.log('inst', inst)
}
}
<select id="mySelect" onChange={this.onDropdownSelected}>
{installations.map(installation =>
<option key={installation._id} name={installation._id} value=
{JSON.stringify(installation)}>{installation.name}</option>)}
</select>
【问题讨论】: