某个页面,有多个列表,如100行,这时需要实现分页功能,手机端的分页一般都是滑到底部时上拉刷新。
使用scroll-view实现,其bindscrolltolower方法:滚动到底部/右边触发。当触发时发送请求获取新的数据,我写的时候获取的数据很快,我还给它加了个定时器啊哈哈哈,因为我想让showLoading加载弹窗转一转,让用户知道上拉刷新数据。因为没加的时候showLoading一闪而过,感觉体验效果不好。
最后scroll-view使用竖向滚动时,需要给<scroll-view/>
一个固定高度(height:93%),再给page设置高度(height:100%),否则bindscrolltolower触发不了
<scroll-view wx:if="{
{isShowList}}" class='scrollHeight' scroll-y="true" bindscrolltolower="getMore" lower-threshold='3'>
</scroll-view>
来一段逻辑的代码
//上拉加载分页
getMore(e){
var that = this;
var user = wx.getStorageSync('bizUser');
wx.showLoading({
title: '正在加载中',
});
setTimeout(function(){
var pageindex