ListItem头像未显示 [英] ListItem Avatar Not Displaying
本文介绍了ListItem头像未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
作为 FlatList
的一部分,我渲染每个 ListItem
(来自 react-native-elements
库),在其中尝试显示从网址到照片的头像(图标):
As part of a FlatList
, I render each ListItem
(from the react-native-elements
library) where I try to display an avatar (icon) from a url to a photo:
<ListItem
avatar={{ source: { uri: item.icon } }}
/>
所有其他道具都可以正常显示,但是在每个单元格的左侧,我只得到一个灰色框.我已经记录了 item.icon
的值,它指向有效的照片.我需要下载照片,然后提供本地链接吗?
All the other props display fine but on the left side of each cell I just get a grey box. I've logged the value of item.icon
and it points to a valid photo. Do I need to download the photo and then provide a local link to it?
如何使照片显示为单元格的化身?
How can I get the photo to show up as the cell's avatar?
推荐答案
您为图像头像使用了错误的对象.
You're using the wrong object for the image avatar.
任一
avatar={{ uri: item.icon }}
OR
avatar={<Avatar
rounded
source={{uri: item.icon}}
title={'Sample Title'}
/>}
测试版
leftAvatar={{ source: { uri: item.icon } }}
这篇关于ListItem头像未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文