chat - 如何显示存储在变量中的图像?
问题描述
在天才聊天中,有一个image
字段可以是指向要显示的图像的 URL。这是一个消息示例:
{
_id: 30,
createdAt: new Date(),
image: 'https://upload.wikimedia.org/wikipedia/commons/thumb/6/6e/Paris_-_Eiffelturm_und_Marsfeld2.jpg/280px-Paris_-_Eiffelturm_und_Marsfeld2.jpg',
user: {
_id: 2,
name: 'React Native',
},
},
对于存储在变量中的图像文件img
,如何在聊天消息中显示它?message.image = img
不工作。
解决方案
您可以将 url 传递给源。
喜欢
<Image
source={{uri: img}}
/>
推荐阅读
- python - 'range(y.shape[1])' 在“for i in range(dataset2.shape[1]):”中是什么意思?
- powershell - 在 powershell 中使用文件名创建目录
- android - Action Bar android 改变高度
- python - 我可以使用 numpy.polyfit(x, y, deg) 进行多元线性回归吗
- shell - 使用 shell 命令提取版本
- linux-kernel - 无法以非 root 身份运行 bpf 程序
- javascript - 在heroku中提交值后如何解决cannot /get/product错误
- solr - 无法使用 Oracle 数据库在 Apache Solr 中执行数据导入处理程序
- linux - ptp4l 主偏移、频率和路径延迟的高值
- javascript - 如何在反应导航5中覆盖标题标题