下方监听事件写在 methods 方法的同级下面
// 监听表格滚动
directives: {
loadmore: {
bind(el, binding) {
let bottomingOutFlage = true;
const selectWrap = el.querySelector(".el-table__body-wrapper");
selectWrap.addEventListener("scroll", function () {
const scrollDistance =
this.scrollHeight - this.scrollTop - this.clientHeight;
if (bottomingOutFlage) {
if (scrollDistance <= 0.5) {
bottomingOutFlage = false;
setTimeout(() => {
bottomingOutFlage = true;
}, 100)
binding.value()//执行在使用时绑定的函数,在这里即loadMorePerson方法
}
}
});
},
},
},