js滚动加载

    // 滚动加载
    function onScroll() {
        if (this.curPage > this.totalPage) return;
        var scrollTop = document.body.scrollTop || document.documentElement.scrollTop;
        var scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
        var windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
        if (scrollTop + windowHeight > scrollHeight - 100) {
            // flagData防止触发多次
            if (!this.flagData) return;
            this.flagData = false;
            this.getSingerList();//请求数据成功后 page+1, this.flagData = true;
        }
    }
原文地址:https://www.cnblogs.com/yuesu/p/10315943.html