某些机型下滑数据不刷新问题处理

 1 $(window).scroll(function() {
 2                   var scrollTop = $(this).scrollTop();
 3                   var scrollHeight = $(document).height();
 4                   var windowHeight = $(this).height();
 5                   if(scrollTop == 0){
 6                       console.log('触顶');
 7                      getList();
 8                  }
 9                               
10                  if(scrollTop + windowHeight == scrollHeight  ){
11                       console.log('下拉到底了');
12                       getList(curIdx, param, "1");
13                  }                                
14         })


  某些机型下滑到底时 scrollTop + windowHeight 不等于 scrollHeight 导致不能刷新数据, 所以代码修改为

 1 $(window).scroll(function() {
 2                   var scrollTop = $(this).scrollTop();
 3                   var scrollHeight = $(document).height();
 4                   var windowHeight = $(this).height();
 5                   if(scrollTop == 0){
 6                       console.log('触顶');
 7                      getList();
 8                  }
 9                               
10                  if((scrollTop + windowHeight)/scrollHeight > 0.95  ){
11                       console.log('下拉到底了');
12                       getList(curIdx, param, "1");
13                  }                                
14         })

  代码 (scrollTop + windowHeight)/scrollHeight > 0.95 中的0.95是实验性的取值, 可以按照实际情况调整

原文地址:https://www.cnblogs.com/wawadao/p/14602163.html