loadmore

func

1
2
3
4
5
6
7
8
9
10
11
12
13
14
loadmore(e) {
let element = e.target;
try {
e.stopPropagation();
} catch (ex) {

}
let clientHeight = element.clientHeight; //可视区域高度
let scrollTop = element.scrollTop; //滚动条滚动高度
let scrollHeight = element.scrollHeight; //滚动内容高度
if (scrollTop > 0 && (clientHeight + scrollTop) >= scrollHeight) { //如果滚动到底部
this.getlist('more');
}
}

html

1
2
3
<div className="content_all" style={{maxHeight: ${divHeight}px, height: ${divHeight}px, overflow: 'auto'}}
onScroll={this.loadmore}>
</div>

^-^欢迎回复交流^-^