本文轉載自: 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; }