内部平面列表如何从JSON数据动态传递密钥
Data:[{b:'1',c:'2',d:'3',e:'4'},
{b:'5',c:'6',d:'7',e:'8'}]
<Text style={{padding:10}}>{item.b}</Text>)}/>
答案 0 :(得分:0)
import { FlatList } from 'react-native'; // Import FlatList
let data = [{b:'1',c:'2',d:'3',e:'4'},{b:'5',c:'6',d:'7',e:'8'}]; // Declare your array.
// Add FlatList into your view
<FlatList
data={data}
renderItem={this.renderListItem}
keyExtractor={(item, index) => index.toString()}
/>
// In renderListItem, each object in the array will be passed in as a parameter.
renderListItem = ({ item }) => (
<Text style={{padding:10}}>{item.b}</Text>)}/>
);