- 在使用uni-app的时候, 忽然发现ios在使用onPullDownRefresh方法下拉刷新的时候 可以看到后台会一连访问几十次
onPullDownRefresh() {
uni.startPullDownRefresh({})
this.getCommend(this.mobile)
let url = '/product/mobile/list'
if (this.mobile != '') {
url += '?mobile=' + this.mobile
}
this.apireq.req({
url: url,
mothod: 'GET',
success: (res) => {
this.current = 0
this.classInfoList = []
this.setData = []
this.classInfoList = res.data
this.setData = res.data.slice(this.current, this.current + 2)
this.current = this.current + 2
uni.stopPullDownRefresh()
}
})
},
- 经过查看文档发现, 原来是 onPullDownRefresh方法 使用后, 只要下拉就已经触发事件, 不能再使用
uni.startPullDownRefresh()
- 只需要在数据请求完成后使用 uni.stopPullDownRefresh 停止刷新就可以了