* scrollHeight 获取元素内容高度(只读)
* scrollTop 获取或者设置元素的偏移值,常用于, 计算滚动条的位置,
* 当一个元素的容器没有产生垂直方向的滚动条, 那它的scrollTop的值默认为0.
* clientHeight 读取元素的可见高度(只读)
1. 一般div的滚动条
getScroll(event) {
let scrollHeight = event.target.scrollHeight
let scrollTop = event.target.scrollTop
let clientHeight = event.target.clientHeight
let scrollBottom = scrollHeight - scrollTop - clientHeight
console.log(scrollBottom)
this.showMore = scrollBottom < 1
},
2. element-ui 中table滚动条
mounted () {
this.dom = this.$refs.table.bodyWrapper
this.dom.addEventListener('scroll', () => {
let scrollTop = this.dom.scrollTop
let scrollHeight = this.dom.scrollHeight
let clientHeight = this.dom.clientHeight
let scrollBottom = scrollHeight - scrollTop - clientHeight
console.log(scrollBottom)
this.showDetail = scrollBottom < 1
})
},