自定义指令
directives: {
tableInfiniteScroll: {
bind(el, binding) {
let tbody = el.querySelector(".el-table__body-wrapper");
el.tableInfiniteScrollFn = function () {
if (this.scrollHeight - this.scrollTop - this.client == 0) {
binding.value();
}
};
tbody.addEventListener("scroll", el.tableInfiniteScrollFn);
tbody = undefined;
},
unbind(el) {
let tbody = el.querySelector(".el-table__body-wrapper");
tbody.removeEventListener("scorll", el.tableInfiniteScrollFn);
el.tableInfiniteScrollFn = undefined;
},
},
},
我的表格列配置是动态的所以我的表格高度是自适应的
<el-table v-table-infinite-scroll="load"
max-height="我自己设置的最大高度,我是进入页面获取父元素的高度设置的"></el-table>