1、给滚动条增加监听
this.dom = this.$refs.tableRef.bodyWrapperthis.dom.scrollTop = 0let _that = thisthis.dom.addEventListener('scroll', () => {//获取元素的滚动距离let scrollTop = _that.dom.scrollTop//获取元素可视区域的高度let clientHeight = this.dom.clientHeight//获取元素滚动条的高度let scrollHeight = this.dom.scrollHeightif (scrollTop + clientHeight == scrollHeight) {//不是获取全部数据,而是加载新的数据}console.log(`scrollTop: ${scrollTop}`)console.log(`clientHeight: ${clientHeight}`)console.log(`scrollHeight: ${scrollHeight}`)})
2、滚动条滑动到指定为止
只需要给scrollTop 赋值就行了
//滚动条滑动到指定位置
this.dom.scrollTop = this.dom.scrollHeight + 300