React Native 圖片查看組件的方法
React Native 圖片查看組件:react-native-image-viewer,純JS組件,小巧快速的圖標(biāo)查看組件。支持圖片放大縮小,支持圖片加載失敗設(shè)置替代圖片,支持將圖片保存到本地等功能。
效果圖
安裝方法
npm i react-native-image-zoom-viewer --save
使用示例
const images = [ { url: 'https://avatars2.githubusercontent.com/u/7970947?v=3&s=460', }, { url: 'https://avatars2.githubusercontent.com/u/7970947?v=3&s=460', }, { url: 'https://avatars2.githubusercontent.com/u/7970947?v=3&s=460', }, ]; export default class Component06 extends Component { constructor(props) { super(props); } render() { return ( <View style={{ flex: 1 }}> <ImageViewer imageUrls={images} failImageSource={{ url: 'https://avatars2.githubusercontent.com/u/7970947?v=3&s=460', width: Dimensions.get('window').width, height: Dimensions.get('window').width, }} /> </View> ); } }
主要參數(shù)說明
- imageUrls 圖片url地址的數(shù)組
- enableImageZoom 是否允許縮放
- failImageSource 加載失敗時顯示的圖片
- loadingRender 加載loading
- renderHeader 頭部樣式
- renderFooter 底部樣式
- renderIndicator 頁碼指示器樣式
完整示例
完整代碼:https://github.com/forrest23/ReactNativeComponents 本次示例代碼在 Component06文件夾中。
組件地址:https://github.com/ascoders/react-native-image-viewer
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
React中實現(xiàn)keepalive組件緩存效果的方法詳解
由于react官方并沒有提供緩存組件相關(guān)的api(類似vue中的keepalive),在某些場景,會使得頁面交互性變的很差。所以本文為大家介紹了React中實現(xiàn)keepalive組件緩存效果的方法,希望對大家有所幫助2023-01-01react中關(guān)于Context/Provider/Consumer傳參的使用
這篇文章主要介紹了react中關(guān)于Context/Provider/Consumer傳參的使用,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-09-09詳解webpack + react + react-router 如何實現(xiàn)懶加載
這篇文章主要介紹了詳解webpack + react + react-router 如何實現(xiàn)懶加載,具有一定的參考價值,感興趣的小伙伴們可以參考一下。2017-11-11使用webpack搭建react開發(fā)環(huán)境的方法
本篇文章主要介紹了使用webpack搭建react開發(fā)環(huán)境的方法,在這篇文章中我們開始利用我們之前所學(xué)搭建一個簡易的React開發(fā)環(huán)境,用以鞏固我們之前學(xué)習(xí)的Webpack知識。一起跟隨小編過來看看吧2018-05-05