时间:2021-07-01 10:21:17 帮助过:7人阅读
React Native 图片查看组件:react-native-image-viewer,纯JS组件,小巧快速的图标查看组件。支持图片放大缩小,支持图片加载失败设置替代图片,支持将图片保存到本地等功能。
效果图
安装方法
- 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>
- );
- }
- }
主要参数说明
完整示例
完整代码:https://github.com/forrest23/ReactNativeComponents 本次示例代码在 Component06文件夹中。
组件地址:https://github.com/ascoders/react-native-image-viewer
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。