react中使用antd Table组件滚动加载数据的实现

6,161 阅读1分钟
import React from 'react';
import { Table } from 'antd';

class TablePanel extends React.Component {

  onScrollEvent=()=> {
    if (this.scrollRef.scrollTop + this.scrollRef.clientHeight ===         
      this.scrollRef.scrollHeight) {
        console.info('到底了!');
        // todo 异步数据加载
    }
  }

  render() {
    return (
      <div ref={c => this.scrollRef = c}
           style={{ minHeight: 200, overflowY: 'scroll' }}
           onScrollCapture={this.onScrollEvent}>
        <Table ...params/>
      </div>
    );
  }
}

export default TablePanel;

来源链接:www.cnblogs.com/zyl-Tara/p/…