监听滚动到底部事件:
function isScrollToBottom() {const scrollTop = document.documentElement.scrollTop || document.body.scrollTop;const scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;const clientHeight = document.documentElement.clientHeight || document.body.clientHeight;return scrollTop + clientHeight >= scrollHeight-100;
}
在mounted里增加监听scroll:
mounted() {let _this = thisthis.dataList = this.originDatawindow.addEventListener('scroll', function () {// 判断是否滚动到了底部if (isScrollToBottom() && !_this.loading) {_this.loading = true;// 加载更多内容_this.loadmore()}});},
这样就可以触底loadmore了。。
参考链接:
vue-waterfall2的简介及使用教程 - Made with Vuejs
实现当滚动到页面底部时,加载更多内容_在最底部的分页 切换时 底部变多-CSDN博客