Firebase 遍历数组对象以显示多个图像
我试图遍历“photo”数组中的所有“url”,并将其显示在我的react原生应用程序的提要页面上。以下是我在平面列表中的操作方式:Firebase 遍历数组对象以显示多个图像,firebase,react-native,object,firebase-realtime-database,react-native-flatlist,Firebase,React Native,Object,Firebase Realtime Database,React Native Flatlist,我试图遍历“photo”数组中的所有“url”,并将其显示在我的react原生应用程序的提要页面上。以下是我在平面列表中的操作方式: <View> { (item.photo).map(photoItem => ( <Image source={{
<View>
{
(item.photo).map(photoItem => (
<Image
source={{ uri: photoItem.url }}
/>
))
}
</View>
<FlatList
refreshing={this.state.refresh}
onRefresh={this.loadNew}
data={this.state.photo_feed}
keyExtractor={(item, index) => index.toString()}
style={{ backgroundColor: "#eee", flex: 1 }}
renderItem={({ item, index }) => (
<View key={index} style={styles.flatlistImage}>
<View style={styles.postDetails}>
<Text>{item.posted}</Text>
</View>
<View>
<View>
{
(item.photo).map(photoItem => (
<Image
source={{ uri: photoItem.url }}
style={styles.profilephoto}
/>
))
}
</View>
</View>
</View>
)}
/>
``
我能够获取该值,但无法遍历该值并立即在屏幕上显示所有图像
我得到这个错误:
ReferenceError: Can't find variable: photoItem
以下是完整的平面列表:
<View>
{
(item.photo).map(photoItem => (
<Image
source={{ uri: photoItem.url }}
/>
))
}
</View>
<FlatList
refreshing={this.state.refresh}
onRefresh={this.loadNew}
data={this.state.photo_feed}
keyExtractor={(item, index) => index.toString()}
style={{ backgroundColor: "#eee", flex: 1 }}
renderItem={({ item, index }) => (
<View key={index} style={styles.flatlistImage}>
<View style={styles.postDetails}>
<Text>{item.posted}</Text>
</View>
<View>
<View>
{
(item.photo).map(photoItem => (
<Image
source={{ uri: photoItem.url }}
style={styles.profilephoto}
/>
))
}
</View>
</View>
</View>
)}
/>
``
index.toString()}
风格={{backgroundColor:#eee',flex:1}}
renderItem={({item,index})=>(
{item.posted}
{
(item.photo).map(photoItem=>(
))
}
)}
/>
``
好吧,它应该是item.url而不是item.photo,因为您的对象是这样命名的