微信小程序上划加载下划刷新

获取列表

data: {
	limit: 20,//每次获取的条数
	offset: 0,//偏移量(从第几条获取)
	total: 0,//列表总数
	list: [],//列表
},
getList: function(limit, offset){
	wx.stopPullDownRefresh();//停止当前页面下拉刷新
	//省略获取接口的过程,接口返回值为resTotal,resList
	this.setData({
		total: resTotal,
		list: this.data.list.concat(resList)
	})
},

上划加载

onReachBottom: function() {
    if (this.data.list.length < this.data.total) {
      this.setData({
        offset: this.data.limit + this.data.offset
      })
      this.getList(this.data.limit, this.data.offset);
    }
  }

下划刷新

需在当前页面的json文件设置 “enablePullDownRefresh”: true

onPullDownRefresh: function() {
	this.setData({
        list: [],
        offset: 0
      })
      this.getList(this.data.limit, this.data.offset);
  },
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值