<div class="message-box" data-spy="scroll" data-target="#navbar-example" data-offset="0" ref="messageList" > </div>
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") } }, }