![](/img/trans.png)
[英]How I can display 2 Dimensional JSON Data to my React Native FlatList
[英]How to display JSON data in FlatList React Native
您需要將“文本”標簽放置在“視圖”標簽以及keyExtractor中
import React, { Component } from 'react';
import { Platform, StyleSheet, Text, View, FlatList, Image, ScrollView, Picker } from 'react-native';
export default class Test extends Component {
constructor() {
super();
this.state = {
data : [
{"Begin" : "08:00:00" ,End : "08:10:00"},
{"Begin" : "08:10:00" ,End : "08:20:00"},
{"Begin" : "08:20:00" ,End : "08:30:00"},
{"Begin" : "08:30:00" ,End : "08:40:00"},
{"Begin" : "08:40:00" ,End : "08:50:00"},
{"Begin" : "08:50:00" ,End : "08:60:00"},
]
}
}
_keyExtractor = (item, index) => item.Begin.toString();
render() {
return (
<View style={{flex:1,justifyContent:'center'}}>
<FlatList
data={this.state.data}
keyExtractor={this._keyExtractor}
renderItem={({item}) => <Text> {item.Begin} </Text> }
/>
</View>
)
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.