[英]React Native Image displays different src url
In react native, the <Image>
tag isn't displaying properly and shows an image from a different src URL in the database.在 react native 中,
<Image>
标记无法正确显示,并显示来自数据库中不同 src URL 的图像。 I checked the URL multiple times, and it isn't the one displayed in the HTML.我检查了 URL 多次,它不是 HTML 中显示的那个。
<Image source={{uri: image}} style={styles.image} />
What is causing this glitch?是什么导致了这个故障?
Your browser caches your url and assumes you are hitting the same url so it populates previous result.您的浏览器缓存您的 url 并假设您正在访问相同的 url,因此它会填充先前的结果。 Add a random query to the url like:
向 url 添加随机查询,例如:
https://source.com/a/b/c/image.png?randomQuery={random_number_here}
Example:例子:
https://i.pinimg.com/564x/62/ed/6e/62ed6ea71018a57a3ab0c8c959d78cb0.jpg?key=1656566265232
https://i.pinimg.com/564x/62/ed/6e/62ed6ea71018a57a3ab0c8c959d78cb0.jpg?key=1656566265232
React native:反应原生:
<Image
source={{ uri: `${imageUrl}?key=${Date.now()}` }}
/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.