- 在使用uni-app的时候, 忽然发现ios在使用onPullDownRefresh方法下拉刷新的时候 可以看到后台会一连访问几十次
// 页面下拉
onPullDownRefresh() {
uni.startPullDownRefresh({}) // 开启刷新, 但是在这里不能再用了,因为onPullDownRefresh已经自动开启刷新了
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) => {
// console.log(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
// console.log(this.current, this.setData)
uni.stopPullDownRefresh()
}
})
},
- 经过查看文档发现, 原来是 onPullDownRefresh方法 使用后, 只要下拉就已经触发事件, 不能再使用
uni.startPullDownRefresh() - 只需要在数据请求完成后使用 uni.stopPullDownRefresh 停止刷新就可以了
版权声明:本文为weixin_45289067原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。