antd组件的methods怎么调用

图片描述

ant design组件里类似于这种方法是怎么调用的,这不像组件的参数。不知道怎么使用,求教。

阅读 7.9k
2 个回答
  constructor(props) {
    super(props);

    this.carouselRef = null;

    this.setCarouselRef = el => {
      this.carouselRef = el;
    };
  }

  componentDidMount() {
    // 调用
    if (this.carouselRef) this.carouselRef.next();
  }

  // render部分
  <Carousel ref={this.setCarouselRef} ></Carousel>

如果我按钮事件是在另一个组件这个怎么传输,给组件绑定ref打印出来的是这样的
图片描述

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题