react.js antd carousel with arrows

后端 未结 7 2080
既然无缘
既然无缘 2021-01-12 11:26

I am looking at using the antd Caroseul, but I\'ve not seen an example that creates a prev/next or pause button.

const { Carousel } = antd;

ReactDOM.render         


        
7条回答
  •  爱一瞬间的悲伤
    2021-01-12 11:39

    import React, { Component } from "react";
    import { Carousel, Icon } from "antd";
    
    export default class CarouselComponent extends Component {
      constructor(props) {
        super(props);
        this.next = this.next.bind(this);
        this.previous = this.previous.bind(this);
        this.carousel = React.createRef();
      }
      next() {
        this.carousel.next();
      }
      previous() {
        this.carousel.prev();
      }
    
      render() {
        const props = {
          dots: true,
          infinite: true,
          speed: 500,
          slidesToShow: 1,
          slidesToScroll: 1
        };
        return (
          
    (this.carousel = node)} {...props}>

    1

    2

    3

    4

    ); } }

提交回复
热议问题