1.0.0 • Published 5 years ago

imgpreview-react v1.0.0

Weekly downloads
10
License
ISC
Repository
github
Last release
5 years ago

React ImagePreview

图片预览与查看器,自动适应移动端,只需提供图片地址数组即可,自动计算图片宽高,自适应显示

install

npm install imgpreview-react  -S

example

import React from "react"
import ImagePreview from "imgpreview-react";

class App extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      visible: true
    };
  }

  onClose = () => {
    this.setState({
      visible: false
    });
  };

  render() {
    const imgs = [
      "./1.jpg",
      "./2.jpg",
      "./3.jpg",
      "./4.jpg",
    ];

    return (
      <div>
        <ImagePreview
          imgs={imgs}
          visible={this.state.visible}
          onClose={this.onClose}
          width={1000}
          height={500}
        />
      </div>
    );
  }
}

api

参数说明类型默认值是否必须
imgs图片预览地址数组arrayundefined
cIndex当前预览的图片下标number0
width图片预览器的宽度number800
height图片预览器的高度number500
visible图片预览器是否显示boolundefined
onClose图片预览器关闭时回调functionundefined
showClose是否显示关闭按钮booltrue
showThumbnail是否显示底部缩略图booltrue