Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Firebase 遍历数组对象以显示多个图像_Firebase_React Native_Object_Firebase Realtime Database_React Native Flatlist - Fatal编程技术网

Firebase 遍历数组对象以显示多个图像

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={{

我试图遍历“photo”数组中的所有“url”,并将其显示在我的react原生应用程序的提要页面上。以下是我在平面列表中的操作方式:

                    <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,因为您的对象是这样命名的