【问题标题】:How to render image component based on the image uri inside an array in react native如何在本机反应中基于数组内的图像uri渲染图像组件
【发布时间】:2019-08-29 13:01:59
【问题描述】:
我有一个图像 URI 数组。
["file:///data/user/0/com.app.outlet/cache/react-native-image-crop-picker/22536474236950.png","file:///data/user/0 /com.app.outlet/cache/react-native-image-crop-picker/22583225016770.png"]
我想根据数组的长度来渲染图像组件并显示和显示所有图像。我该如何在本机反应中做到这一点
【问题讨论】:
标签:
image
react-native
components
【解决方案1】:
我相信这会对您有所帮助,请先阅读如何提问……
var array = ["file:///data/user/0/com.app.outlet/cache/react-native-image-crop-picker/22536474236950.png","file:///data/user/0/com.app.outlet/cache/react-native-image-crop-picker/22583225016770.png"]
array.map((x)=>{
return(<Image source={x || whatever you want } style={{xx:"xx"}} />)
})
【解决方案2】:
如果数组中有图像,则可以使用地图功能并显示在图像组件中
数据 = ['a.png',b.png']
data.map((item,index)=>{
这只是演示示例