微信小程序实现下拉刷新

138 阅读1分钟

首先需要再page.json中开启下拉刷新:

image.png

同样实现下拉刷新需要触发生命周期函数:onPullDownRefresh()

image.png

// 下拉刷新的事件
onPullDownRefresh() {
  // 1. 重置关键数据
  this.queryObj.pagenum = 1
  this.total = 0
  this.isloading = false
  this.goodsList = []

  // 2. 重新发起请求
  this.getGoodsList(() => uni.stopPullDownRefresh())
}