javascript - 我想从包含图像的链接/网址的数组中返回平面列表中的图像 react-native
问题描述
我想返回 flatlists 中的图像。首先这个数组 qwer[] 包含 url 链接图像 init 它甚至 console.logs 它从 api 获取链接。我已经手动尝试将图像放入带有源的 View 标记中,它可以工作。但是当我使用平面列表时,它没有显示错误但不显示图像。你能帮帮我吗?
return(
<FlatList
horizontal
showsHorizontalScrollIndicator={false}
data={qwer}
renderItem={({ item }) => (
<Image
source={({uri:item})}
style={{
width:260,
height:300,
borderWidth:2,
borderColor:'#d35647',
resizeMode:'contain',
margin:8
}}
/>
)}
/>
解决方案
在您的代码中只需替换
source={({uri:item})}
至
source={{uri : item}}
推荐阅读
- javascript - 如何将 Object {} 转换为一维数组?
- html - 图像未显示在 S3 URL 的 Thymeleaf 图像 src 中
- heroku - Heroku GUI 在多种情况下显示“未知错误”
- javascript - rollup.js - 如何加载捆绑的 CSS?
- mysql - Amazon VPC:将默认 VPC 服务器连接到非默认 VPC 服务器
- python - 在规则中的函数中使用通配符
- spring-kafka - 如何访问 SCDF 流中的源本机标头?
- pandas - 与首先选择列相比,对整个数据框进行分组,然后是过滤列是否占用更多内存?
- intellij-idea - IntelliJ - 前一天的提示
- rtmp - RTMP客户端什么时候发起deletestream()的操作