uni-app scroll-view 实现上拉加载更多数据

使用scroll-view 组件包裹元素,为页面底部添加正在加载动画,可以使用组件 uLi-load-more,直接点击 使用HBuilder 导入插件,可以不用引入和注册该组件,但 HBuilderX版本应高于2.5.5

// lower-threshold 距离底部 30 触发事件
<scroll-view class="orderlist" scroll-y="true" lower-threshold="30" @scrolltolower="scrollLower">
	<view class="" style="height: 70rpx;">元素</view>
	// 加载动画组件
	<uLi-load-more status="loading"></uLi-load-more>
</scroll-view>

data(){
	return{
		page:1, // 第一页 
		allpage:0, // 总页数
		status:"loading" // 加载状态
	}
}

方法

scrollLower(){
		if(this.page>=this.allpage){
			this.status="noMore"
			return ;
		}else{
			this.status="loading"
		}
		this.page++
		this.getData();
		console.log('我滚动到底部了')
}

滚动高度

<style>
	.orderlist{
		position: absolute;
		bottom: 0;top:70rpx;
		width: 100%;
	}
</style>
  • 2
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值