失去互联网连接后图像消失

时间:2019-08-22 11:00:21

标签: javascript image react-native

我在我的本机项目中将图像显示为徽标。当我有互联网连接时,它显示正常。但是,如果我关闭互联网,它就会消失。

谁能告诉我我在做什么错了。

<Component {...props} renderItem={other component}/>

url =“ https://reactnativecode.com/wp-content/uploads/2017/05/react_thumb_install.png

1 个答案:

答案 0 :(得分:0)

如果要离线表达相同的cache,则可以image image

但是它仅在iOS中有效。而且必须加载一次。

<Image style={{resizeMode: 'contain', height: 40, width: 130}}

 source={{uri: this.props.logoImage.logoImage.ImageVirtualPath, cache: 'only-if-cached'}} />

如果要在任何设备上运行,则可以安装和使用该模块。

您可以安装React-native-cached-image

示例

import { CachedImage } from 'react-native-cached-image';
...
<CachedImage 
  style={{
    width: 200,
    height: 200,
  }}
  source={{ uri: item.urls.raw }}
/>