本文原创首发于公众号: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开发圈数组