其他分享
首页 > 其他分享> > uni-app 滑动到最右边或者触底分页加载数据

uni-app 滑动到最右边或者触底分页加载数据

作者:互联网

HTML

<scroll-view class="todaysDeal-scroll" :scroll-x="true" enable-flex="true" @scrolltolower="scorllClick">
   <view class="todaysDeal-list" v-for="(item,index) in todaysDeal" :key='index'></view>
</scroll-view>

JS

data() {
	return {
	   todaysDeal:[],
	   //默认传参的页数和个数  以及算总页数
	   scollorCurrent: 1,
	   scollorSize: 8,
	}
},

methods:{
scorllClick() {
    //每次触底增加页数
	this.scollorCurrent++
	this.jrtjClick()
},

jrtjClick() {
	var that = this
	var parms = {
		current: that.scollorCurrent,
		size: that.scollorSize,
		}
	that.$u.api.popular(parms).then(res => {
	   that.todaysDeal = that.todaysDeal.concat(res.records)
	   //后续还可以用总数除以个数,获取总共多少页,然后判断你当前翻到的页数大于总页数后做一些提示操作
	})
},

标签:res,app,页数,scollorCurrent,jrtjClick,uni,parms,todaysDeal,加载
来源: https://blog.csdn.net/weixin_45863359/article/details/122126032