我确实有这种JSON。我在我的React Native应用程序上得到它。
order:[
{
"id": "00005497",
"order_number": "525522",
"order_result_json": [
{
"key": "Номер",
"value": "25263640253590"
},
{
"key": "Ссылка на скачивание",
"value": "https://play.google.com/store/"
},
{
"key": "Ссылка на лицензию",
"value": "https://google.com"
}
]
}]
我可以看到数据即将到来:alert(JSON.stringify(order.orderResultJson));这表明数组即将到来。
当我将其应用于FlatList时,它显示出空白,如果向下滚动页面,则将无限滚动带有空白内容。
我的FlatList实现:
<View style={{flex: 1, backgroundColor: 'green'}}>
<FlatList
data={order.orderResult}
renderItem={({item}) => <Text>{item.value}+5</Text>}
keyExtractor={item => item.key}
/>
</View>
有什么建议吗?
答案 0 :(得分:2)
不仅仅是错别字吗?
您的代码使用data={order.orderResult}
,但是您的json数据包含order_result_json
,而带有警报的调试代码使用orderResultJson
答案 1 :(得分:0)
order 是一个数组,因此您无法访问 order.orderResult 。
2个解决方案: