React Native圖片緩存解決方案


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, 

  }}/>

image-progress-demo

傳送門:https://github.com/wcandillon/react-native-img-cache

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM