本文转载自: https://www.jb51.net/article/147462.htm
created() { this.$nextTick(() => { const el = document.querySelector('.activityText'); const offsetHeight = el.offsetHeight; el.onscroll = () => { const scrollTop = el.scrollTop; const scrollHeight = el.scrollHeight; if ((offsetHeight + scrollTop) - scrollHeight >= -1) { // 需要执行的代码 console.log('已滚动到底部') } }; }); },
如果监听元素滚动失效,css改成下面写法。
.wrListBox { width: 100%; height: 100%; overflow-y: scroll; }