1. react-native-fetch-blob 將圖片存在本地的一個東西
2. react-native-img-cache 自動緩存的一個東西
上面裝好后 就可以使用啦
import {CachedImage} from "react-native-img-cache";
<CachedImage source={{ uri: "https://i.ytimg.com/vi/yaqe1qesQ8c/maxresdefault.jpg" }} />
如果想讓圖片有種加載效果
import Image from 'react-native-image-progress';
import ProgressBar from 'react-native-progress/Bar';
最后使用
import {CustomCachedImage} from "react-native-img-cache";
import Image from 'react-native-image-progress';
import ProgressBar from 'react-native-progress/Bar';
<CustomCachedImage
component={Image}
source={{ uri: 'http://loremflickr.com/640/480/dog' }}
indicator={ProgressBar}
style={{
width: 320,
height: 240,
}}/>
傳送門:https://github.com/wcandillon/react-native-img-cache