核心方法:
handleScroll: function () { var scrollTop = document.documentElement.scrollTop || document.body.scrollTop; var windowHeitht = document.documentElement.clientHeight || document.body.clientHeight; var scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight; if (scrollTop + windowHeitht >= scrollHeight - 2000) { if (this.scroll) { this.GetSpecialData(); } } }, GetSpecialData() { this.scroll = false; this.page.pageIndex++; this.load(this.page, this.query); },
监听:
mounted() { window.addEventListener("scroll", this.handleScroll); }, destroyed() { window.removeEventListener("scroll", this.handleScroll, false); },