【发布时间】:2022-01-02 12:59:26
【问题描述】:
我正在从 Firestore 中检索图像,但它在图像区域中显示了这一点。我无法解决这个问题。
方法:
useLayoutEffect(() => {
const unsubscribeimage = db
.collection("token")
.onSnapshot((snapshot) =>
setPhoto(
snapshot.docs.map((doc) => ({
id: doc.id,
dataimg: doc.data(),
}))
)
);
return unsubscribeimage;
}, []);
我的返回码:
<View { photo.map(({dataimg,id }) =>
<View style={styles.sender} key={id}>
<Avatar source={{uri: dataimg}} style={{ width: 200, height: 200 }} />
</View>
我正在获取这张图片:
【问题讨论】:
-
doc.data()不会返回字符串,而是返回具有imageURL属性的对象。Avatar在其source属性中期望什么? -
好的,我怎样才能在源代码中显示图像?头像就是图片标签,我只想展示图片。
-
阿凡达是否期望其
source属性的字符串?如果是这样,那么它将是source={dataimg.imageURL}。它是否期望具有uri属性的对象是一个字符串?如果是这样,那么它将是source={{ uri: dataimg.imageURL }}。如有其他请提供头像相关代码。 -
是的 Avatar 可以接受 oject。谢谢你的工作你让我的一天新年快乐
-
@NicholasTower 感谢您的帮助。 ???想把它写下来作为答案,这样我们就可以结束这个问题了吗?
标签: reactjs firebase react-native google-cloud-firestore