本文原創首發於公衆號:ReactNative開發圈,轉載需註明出處。react
React Native 圖片查看組件:react-native-image-viewer,純JS組件,小巧快速的圖標查看組件。支持圖片放大縮小,支持圖片加載失敗設置替代圖片,支持將圖片保存到本地等功能。
npm i react-native-image-zoom-viewer --save
git
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> ); } }
完整代碼:https://github.com/forrest23/ReactNativeComponents
本次示例代碼在 Component06文件夾中。請不要吝嗇大家的Star!github
https://github.com/ascoders/react-native-image-viewernpm
微信不讓跳轉外鏈,能夠點擊查看原文來查看外鏈GitHub內容。react-native
舉手之勞關注個人微信公衆號:ReactNative開發圈數組