基于onscroll事件實(shí)現(xiàn)的loadmore(es6)
`loadmore(e) {
? let element = e.target;
? try {
? ? e.stopPropagation();
? } catch (ex) {
? }
? let clientHeight = element.clientHeight; //可視區(qū)域高度
? let scrollTop = element.scrollTop;? //滾動(dòng)條滾動(dòng)高度
? let scrollHeight = element.scrollHeight; //滾動(dòng)內(nèi)容高度
? if (scrollTop > 0 && (clientHeight + scrollTop) >= scrollHeight) { //如果滾動(dòng)到底部
? ? this.getlist('more');
? }
}
`
<div className="content_all" style={{maxHeight: `${divHeight}px`, height: `${divHeight}px`, overflow: 'auto'}}
? ? ? ? ? ? ? onScroll={this.loadmore}>
</div>