const index = document.getElementsByClassName(‘selectScroll‘).length;
for (let i = 0; i < index; i++) {
const node = document.getElementsByClassName(‘selectScroll‘)[i].previousElementSibling.children[0];
node.onscroll = (e) => {
const { pageTotal, selectLoading } = this.state; // 数据总条数,加载状态
const { clientHeight, scrollHeight, scrollTop } = e.target;
if ((clientHeight + scrollTop === scrollHeight) && !selectLoading) {
this.setState({
selectCurPage: this.state.selectCurPage + 1, // 页数加一
}, () => {
if (Math.ceil(pageTotal / 15) >= this.state.selectCurPage) { // 懒加载一次加载15条数据
// 这里通过接口去获取数据
}
});
}
};
}