图像正在以相同的uri消失

问题描述 投票:3回答:1

我正在运行示例应用程序。我正在使用amazon s3来存储个人资料照片。所以,我必须使用相同的网址为配置文件图片。我给Image一个独特的关键支柱,试图让它重新加载图像,但它显示一个以前上传的图像。这意味着不清除图像组件的缓存。

我试过下面的代码。图像应该完美更新,但在该屏幕上进行的任何更改都会消失。

此问题仅出现在android中。

 <Image
    source={{uri: this.state.uri + '?' + new Date()}}
    />

请参考此链接: - enter link description here

截图: -

enter image description here

react-native
1个回答
0
投票

将本地const变量设置为

const url = {uri: this.state.uri + '?' + new Date()};

使用网址如下:

<Image
source={uri}
/>
© www.soinside.com 2019 - 2024. All rights reserved.