本文介绍了在本机上缓存图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一个好的库,或者可能有一些默认的本机组件,这些组件可以从url缓存图像?
我已经尝试过,但是和react-native-sqlite-storage有很多问题而且由于我是新手,所以我不知道如何正确解决它们。

Is there a good library or maybe some default react native components that cache the image from a url?I've tried react-native-cache-image but there are a lot of issues with react-native-fs and react-native-sqlite-storage and as I am new to react native I dont know how to fix them properly.

推荐答案

纱线添加react-native-fast-image

yarn add react-native-fast-image

Ref : https://github.com/DylanVann/react-native-fast-image

import FastImage from 'react-native-fast-image'


<FastImage
    style={{ width: 200, height: 200 }}
    source={{ uri: 'https://unsplash.it/400/400?image=1' }}
    resizeMode={FastImage.resizeMode.stretch}

/>

这篇关于在本机上缓存图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-01 18:28