Ant Design Carousel走马灯组件修改

Ant Design Carousel走马灯组件修改

上图
跑马灯截图

借鉴了他人的方法,自己又添加了点内容。大家可点击下方链接去看原博客。

Markov Zheng ————
antd走马灯组件自定义前进后退按钮

index.tsx

import React from "react";
import styles from './index.module.less';
import { Button, Carousel, Col, Row } from 'antd';
import { LeftOutlined , RightOutlined  } from "@ant-design/icons"
//引入底部组件
class Home extends React.Component<any, any>{
  private img: any;
  constructor(props: any) {
    super(props);
    this.state = {};
    this.img = undefined
  }
  prev() {
    this.img.prev();
  }
  next() {
    this.img.next();
  }
  render(): React.ReactElement<any, string | React.JSXElementConstructor<any>> | string | number | {} | React.ReactNodeArray | React.ReactPortal | boolean | null | undefined {

    return (
      <div className={styles.ContentBox}>
        <Row>
          <Col className={styles.center} span={2}><Button className={styles.CarouselIcon} onClick={this.prev.bind(this)} shape="circle" icon={<LeftOutlined  />}/></Col>
          <Col span={20}>
          <Carousel autoplay className={styles.Carousel} ref={dom => { this.img = dom; }}>
            <div><img src='../../../../public/img/logo.png' alt="" /></div>
            <div><img src='../../../../public/img/logo.png' alt="" /></div>
            <div><img src='../../../../public/img/logo.png' alt="" /></div>
            <div><img src='../../../../public/img/logo.png' alt="" /></div>
          </Carousel>
          </Col>
          <Col className={styles.center} span={2}><Button onClick={this.next.bind(this)} shape="circle" icon={<RightOutlined  />}/></Col>
        </Row>
          
      </div>

    );
  }

}
export default Home;

index.module.less

.ContentBox{
    background: #364d79;
}

.Carousel{
    text-align: center;
    justify-content: center;
    margin: auto;
  }
.center{
    text-align: center;
    justify-content: center;
    margin: auto;
}

完。

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值