react antd table滚动条事件如何实现

react antd table滚动条事件如何实现

项目开发中有一个table表格需要做懒加载效果

滚动条事件,就是当table的竖向滚动条到底时,就触发ajax事件再拿一定条数的数据。

阅读 15.8k
1 个回答

可以试试 onScrollCapture 监听

类似这样

<div className={styles.center} onScrollCapture={() => this.onScrollEvent()} ref={c => (this.container = c)}>
...
</div>
constructor(props) {
    super(props);
    this.onScrollEvent = this.onScrollEvent.bind(this);
  }

  onScrollEvent() {
    if (this.container.scrollTop + this.container.clientHeight ===         
      this.container.scrollHeight) {
      // todo
    }
  }
推荐问题