react.js antd 带箭头的轮播 [英] react.js antd carousel with arrows
本文介绍了react.js antd 带箭头的轮播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在考虑使用 antd Caroseul,但我还没有看到创建上一个/下一个或暂停按钮的示例.
const { Carousel } = antd;ReactDOM.render(<轮播自动播放><div><h3>1</h3></div><div><h3>2</h3></div><div><h3>3</h3></div><div><h3>4</h3></div></旋转木马>, document.getElementById('app'));
解决方案
import React, { Component } from "react";import { Carousel, Icon } from "antd";导出默认类 CarouselComponent 扩展组件 {构造函数(道具){超级(道具);this.next = this.next.bind(this);this.previous = this.previous.bind(this);this.carousel = React.createRef();}下一个() {this.carousel.next();}以前的() {this.carousel.prev();}使成为() {const 道具 = {点:对,无限:真实,速度:500,幻灯片显示:1,幻灯片滚动:1};返回 (<div><Icon type="left-circle" onClick={this.previous}/><轮播参考={节点=>(this.carousel = node)} {...props}><div><h3>1</h3>
<div><h3>2</h3>
<div><h3>3</h3>
<div><h3>4</h3>