📜  react-image-lightbox npm - 任何代码示例

📅  最后修改于: 2022-03-11 14:56:44.301000             🧑  作者: Mango

代码示例1
import React, { Component } from 'react';import Lightbox from 'react-image-lightbox';import 'react-image-lightbox/style.css'; // This only needs to be imported once in your app const images = [  '//placekitten.com/1500/500',  '//placekitten.com/4000/3000',  '//placekitten.com/800/1200',  '//placekitten.com/1500/1500',]; export default class LightboxExample extends Component {  constructor(props) {    super(props);     this.state = {      photoIndex: 0,      isOpen: false,    };  }   render() {    const { photoIndex, isOpen } = this.state;     return (      
         this.setState({ isOpen: true })}>          Open Lightbox                 {isOpen && (           this.setState({ isOpen: false })}            onMovePrevRequest={() =>              this.setState({                photoIndex: (photoIndex + images.length - 1) % images.length,              })            }            onMoveNextRequest={() =>              this.setState({                photoIndex: (photoIndex + 1) % images.length,              })            }          />        )}      
    );  }}