js常用方法-列表滚动加载数据

vue项目中没有使用element UI组件的滚动方式;
利用原生的滚动方法进行滚动加载数据,数据加载到最后无数据时停止滚动加载;
实现效果:
初始化个区块列表(发送请求数据列表)显示已加载完毕,滚动触底发送请求显示加载中,请求完成后显示已加载完毕;

1 // 各工单列表滚动分页、在mounted钩子函数中调用 2 scrollAll () { 3 let that = this 4 $('.workOrderPage #scrollWordOrder').off('scroll').on('scroll', function () { 5 let thats = this; 6 let no = +$(this).attr('data-no'); 7 let scrollTop = $(this).scrollTop(); 8 let height = $(this).height(); // 可视区域高度 9 let scrollHeight = $(this)[0].scrollHeight; 10 let heightAll = scrollTop + height; 11 if (heightAll > scrollHeight) { 12 that.scrollGetWordOrder(no); 13 } else if (scrollHeight - heightAll < 1) { 14 that.scrollGetWordOrder(no); 15 } 16 }) 17 },

浙公网安备 33010602011771号