如果是特定id的dom對象的話,使用的是react的ref方法。
//搜索列表鼠標滾動事件
handleScroll(e){
let clientHeight = this.refs.bodyBox.clientHeight; //可視區域高度
let scrollTop = this.refs.bodyBox.scrollTop; //滾動條滾動高度
let scrollHeight = this.refs.bodyBox.scrollHeight; //滾動內容高度
if((clientHeight+scrollTop)==(scrollHeight)){ //如果滾動到底部 }
}
在render
<div className="contentBox" onScroll={this.handleScroll} ref="bodyBox">