Api.getStrongInfo(paramter).then((res) => {
if(!this.searchInitFlag){
console.log("初始化")
this.tableData = res;
setTimeout(()=>{
this.bindScroll(res)
}, 1000)
this.loading = false //加载中样式
this.searchInitFlag = true
}
if(this.selectPointFlag){
console.log("加载")
this.tableData = this.tableData.concat(res)
this.loading = false
}
})
//滚动条加载
bindScroll(res) {
var _this = this
const selectWrap = $('#scrollTable').find(".ivu-table-body.ivu-table-overflowY")[0]
this.selectWrap = selectWrap
const listenerFunction = function(el) {
if (this.scrollHeight == this.scrollTop + this.clientHeight) {//判断滚动条是否滚动到底部
_this.initTable(_this.selectPointFlag)
_this.pageNum++
}
}
selectWrap.addEventListener('scroll', listenerFunction)
}
判断滚动条到底部,需要用到DOM的三个属性值,即scrollTop、clientHeight、scrollHeight。
scrollTop为滚动条在Y轴上的滚动距离。
clientHeight为内容可视区域的高度。
scrollHeight为内容可视区域的高度加上溢出(滚动)的距离。
从这个三个属性的介绍就可以看出来,滚动条到底部的条件即为scrollTop + clientHeight == scrollHeight。