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)
	   //后续还可以用总数除以个数,获取总共多少页,然后判断你当前翻到的页数大于总页数后做一些提示操作
	})
},
上一篇:uni-app v-for用法


下一篇:小程序权限设置:小程序下载图片保存到相册拒绝权限后,再次打开权限的解决方案