4
我该如何处理循环从Json中检索到的结果? 循环Json&显示在React Native中
render: function() {
console.log(this.state.list);
contents = (
<View style={ styles.content }>
<Text>Loaded</Text>
</View>
)
return (
<View style={ styles.container }>
<View style={ styles.header }>
<Text style={ styles.headerText }>XXX</Text>
</View>
<View style={ styles.content }>
{ contents }
</View>
</View>
);
}
确保'this.state.list'对象始终具有'results'数组。你可以添加更多的逻辑来处理你的状态,或者添加if/else条件来获得你想要的内容。 – TrungDQ
我通过使用列表初始化:{result:[]}在getInitialState – CodeGuru
但我得到警告:数组或迭代器中的每个孩子应该有一个唯一的关键支柱,请咨询:) – CodeGuru