uni-app上拉加载

uni-app上拉加载配合插件(LoadMore 加载更多.)完成

html
<scroll-view class="scroll-y list" enableBackToTop="true" scroll-y @scrolltolower="loadMore()">
	<view class="scroll_item" v-for="(item,index) in list" :key="index">
		{{item.name}}
	</view>
	<view class="" v-show="isLoadMore">
		<uni-load-more :status="status"></uni-load-more>
	</view>
</scroll-view>
js
import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue"
export default {
	data() {
		return {
			list:[],  //列表
			pageSize: 10,//每页条数
			pageIndex: 1,//当前页
			total: 0,//总条数
			status:'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
			isLoadMore: false,//是否加载中
		};
	},
	components:{
		uniLoadMore
	},
	onShow() {
	
	},
	methods:{
		// 列表
		getList(){
			HttpService.getQuestionList().then(res=>{
				if(res.code == 0){
					if(res.data.list.length>0){
						this.total = res.data.rowCount
						this.list = this.list.concat(res.data.list)
						if(this.list.length >= res.data.rowCount){
							this.isLoadMore = true
							this.status = 'nomore'
						}
					}else{
						this.isLoadMore = true
						this.status = 'nomore'
					}
					uni.hideLoading();
				}else{
					this.isLoadMore = true
					this.status = 'nomore'
					uni.hideLoading();
					uni.showToast({title:res.msg,icon:'none'})
				}
			})
		},
		// 下拉加载
		loadMore(){
			if(this.pageIndex < this.total/this.pageSize){  //此处判断,上锁,防止重复请求
				this.isLoadMore = true
				this.pageIndex++
				this.getList()
			}
		},
	}
}

简单例子给个参考,自用

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

不想写前端的前端

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值