如果我有一个uris列表:
[
https://example.com/pic1.jpg,
https://example.com/pic2.jpg,
https://example.com/pic3.jpg,
]将状态从0更改为1:
this.setState({ index: 1 })并渲染该图像:
<Image style={...} source={{ uri: images[this.state.index] }} />当pic2.jpg第一次出现时,它会有一个非常丑陋的闪烁。
我有一个场景,我希望用户加载第一个图像,然后点击以设置状态以查看其余图像。以某种方式预加载图像会很好,这样它们就可以在没有闪烁的情况下显示。
有像https://github.com/DylanVann/react-native-fast-image这样的库可以在第一次加载后工作得很好,因为它将被缓存,但我想在我仍然处于第一个uri状态时预加载其他uri。
发布于 2019-03-16 10:37:12
https://stackoverflow.com/questions/55192858
复制相似问题