<分区>
我有一个对象数组:
[
{
id: 1,
name: 'bill'
},
{
id: 2,
name: 'ted'
}
]
寻找一个简单的单行返回:
[
{
value: 1,
text: 'bill'
},
{
value: 2,
text: 'ted'
}
]
因此,我可以使用适当的键轻松地将它们放入 React 下拉列表中。
我觉得这个简单的解决方案应该可行,但我遇到了无效的语法错误:
this.props.people.map(person => { value: person.id, text: person.name })