监听表格dom对象的滚动事件
tableListener() {
console.log("监听表格dom对象的滚动事件")
let that = this;
let dom = that.$refs.myTable.bodyWrapper
dom.addEventListener("scroll", function () {
const scrollDistance = dom.scrollHeight - dom.scrollTop - dom.clientHeight;
// console.log("scroll", scrollDistance)
if (scrollDistance <= 0) { //等于0证明已经到底,可以请求接口
if (that.queryParams.current < Math.ceil(that.total / that.queryParams.size)) {
//当前页数小于总页数就请求
that.queryParams.current++; //当前页数自增
that.getList()
// dom.scrollTop=0
}
}
})
}
获取列表时拼接数据
getList() {
searchFlow({
...this.form,
...this.queryParams,
isSearch: 1
}).then(res => {
this.tableData = [...this.oldData, ...res.data.records]
this.total = res.data.total
this.oldData = [...this.oldData, ...res.data.records]
})
},