html
<div
class="message-box"
data-spy="scroll"
data-target="#navbar-example"
data-offset="0"
ref="messageList"
>
</div>
js
mounted() {
// 缓存指针
let _this = this;
// 注册scroll事件并监听
this.$refs.messageList.addEventListener('scroll', () => {
_this.customEventFun()
});
},
methods: {
//methods start
customEventFun() {
if ((this.$refs.messageList.scrollTop + this.$refs.messageList.clientHeight) >= this.$refs.messageList.scrollHeight) {
console.log(this.$refs.messageList.scrollTop, "滚动高度");
console.log(this.$refs.messageList.clientHeight, "可视区域高度");
console.log(this.$refs.messageList.scrollHeight, "内容高度");
this.$emit("loadData")
}
},
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/283094.html