vue 监听el-table滚动条滚动事件

时间:2025-03-28 16:17:38
data () { scroll: 0, } mounted () { window.addEventListener('scroll',this.handleScroll, true); } destroyed () { window.removeEventListener('scroll', this.handleScroll, true); } methods: { handleScroll () { this.scorll = window.pageYOffset; const that = this; const dom = that.$refs.table.bodyWrapper; // table表格dom const distance = dom.scrollHeight - dom.scrollTop - dom.clientHeight;// 滑动条与底部的距离 console.log(distance) //todo 监听事件之后要做的操作 }} vue 监听el-table滚动条滚动事件,存在一些缺点,比如外层有非表格的滚动条也会被监听到,但仍然能用,最后获取表格的数据就行了。