reactjs - 从数组的索引 0 显示图像反应本机
问题描述
我正在使用 firebase 并为应用程序做出原生反应。帖子已保存,因此“图像”字段是多个图像的数组。但我只想显示第一张图片(索引 0)并且无法让它工作。
非常感谢您的帮助
return (
<View style={styles.container}>
<View style={styles.gallery}>
<FlatList
numColumns={3}
horizontal={false}
data={posts}
renderItem={({ item }) => (
<View
style={styles.imageContainer}>
<Text>{item.name}</Text>
<TouchableOpacity
onPress={() => props.navigation.navigate('PostPage', { postId: item.id})}>
<Image
style={styles.image}
source={{ uri: item.images[0] }} //-> fetched from firebase firestore
/>
</TouchableOpacity>
</View>
)}
/>
</View>
</View>
)
}
解决方案
推荐阅读
- excel - 如果日期范围在某个月份处于活动状态,则 Excel 计数
- c++ - 有效地删除字节数组中的下半字节 - C++
- react-native - 为变量创建存储时出现错误
- java - 如何编辑存储在共享首选项中的自定义对象数组列表中的数据?我正在使用这个类来存储和访问
- reporting-services - 报告变量隐藏表达式的 ReportViewer.Forms SecurityException
- python - 用于非冗余聚类的合成数据生成器
- pyspark - 如何在pyspark中读取excel文件?
- ruby-on-rails - 无法在 ruby on rails 上创建或更新表
- asp.net - 如何在 IIS 中设置我的 ASP.NET 后端?
- reactjs - 如何在 Animated.View 中显示正在播放的音频的进度?