• 网页滚动到底部,拉取数据


    网页滚动模式

    //滚到到底部自动拉取数据
            //页面滚到底部异步加载下一页数据
            $(window).scroll(function () {
                //已经滚动到上面的页面高度
                var scrollTop = parseFloat($(this).scrollTop()),
                    //页面高度
                    scrollHeight = $(document).height(),
                    //浏览器窗口高度
                    windowHeight = parseFloat($(this).height()),
                    totalHeight = scrollTop + windowHeight;
    
                //此处是滚动条到底部时候触发的事件,在这里写要加载的数据,或者是拉动滚动条的操作
                if (scrollTop + windowHeight >= scrollHeight - 0.7) {
    
                    var index = $('.swiper-slide-active').data("index");
                    var id = $('.swiper-slide-active').attr("id");
                    eval(''+id+'('+Number(index)+1+','+pageNumber+',"'+userid+'")');
                }
            });

    可滚动的元素 ,滚动到底部,触发获取数据

    //滚到到底部自动拉取数据
            //页面滚到底部异步加载下一页数据
            $(".swiper-slide").scroll(function () {
                //已经滚动到上面的页面高度
                var scrollTop = parseFloat($(this).scrollTop()),
                    //滚动高度
                    scrollHeight = this.scrollHeight,
                    //窗口高度
                    windowHeight = $(this).height(),
                    totalHeight = scrollTop + windowHeight;
                //此处是滚动条到底部时候触发的事件,在这里写要加载的数据,或者是拉动滚动条的操作
                if (scrollTop + windowHeight >= scrollHeight - 0.7) {
                    console.log("===");
                    var nextIndex = Number($('.swiper-slide-active').data("index"))+1;
                    var id = $('.swiper-slide-active').attr("id");
                    eval('' + id + '(' + nextIndex + ',' + pageNumber + ',"' + userid + '")');
                }
            });
    

      

  • 相关阅读:
    降低大气分
    99999
    88888
    77777
    HandlerThread实现原理
    Android 内存泄漏总结
    Handler实现机制,同步屏障,IdleHandler
    launcher 配置
    微信小程序 上传图片七牛
    微信小程序 跳转传参数 传对象
  • 原文地址:https://www.cnblogs.com/yanqin/p/7127644.html
Copyright © 2020-2023  润新知