【发布时间】:2018-12-11 16:52:56
【问题描述】:
我有一个 JSON,也可以通过 http://myjson.com/kfd04 访问
{
"response": [
{
"id": "1",
"customer": "Star Wars",
"project": "1977"
},
{
"id": "2",
"customer": "Star Wars",
"project": "1985"
},
{
"id": "3",
"customer": "The Matrix",
"project": "1999"
},
{
"id": "4",
"customer": "Inception",
"project": "2010"
},
{
"id": "5",
"customer": "Interstellar",
"project": "2014"
}
]
}
我只想呈现唯一的客户这是我到目前为止的代码。它显示所有客户。 responseData 包含对象的“响应”数组。
<Picker
mode="dialog"
selectedValue={this.state.customerName}
onValueChange={(itemValue, itemIndex) => {
this.setState({ customerName: itemValue });
}
}
>
{
this.state.responseData.map((item) => (
<Picker.Item label={item.customer} value={item.customer} key={item.customer} />))
}
</Picker>
【问题讨论】:
-
在渲染前尝试过滤掉值
标签: javascript reactjs react-native ecmascript-6