uni-app 特定情况下stopPullDownRefresh无效的问题

uni-app 特定情况下stopPullDownRefresh无效的问题

开发环境 版本号 项目创建方式
Windows 11 HBuilderX

产品分类:
uniapp/H5

浏览器平台:
微信内置浏览器

App下载地址或H5网址:
https://pfye7w.test.tlbpg.com/


示例代码:

onPullDownRefresh() {
    this.current = 1
    this.list1 = []
    this.list2 = []
    this.geIndex()
    uni.stopPullDownRefresh()
},

更多关于uni-app 特定情况下stopPullDownRefresh无效的问题的实战教程也可以访问 https://www.itying.com/category-93-b0.html

6 回复

您好,麻烦发下可复现demo

更多关于uni-app 特定情况下stopPullDownRefresh无效的问题的实战教程也可以访问 https://www.itying.com/category-93-b0.html


因为涉及到微信授权,代码包含微信小程序ID等信息,不方便呀

回复 zzgxx: 你不是h5的项目吗?

回复 DCloud_UNI_JBB: 微信服务号ID等信息,写错了

回复 DCloud_UNI_JBB: 可以用我发的地址测试这个BUG,具体需要看哪一部分的代码我可以单独发给你

在你的代码中,uni.stopPullDownRefresh()onPullDownRefresh 方法中立即调用,这会导致下拉刷新动画过早结束,尤其是在异步操作 this.geIndex() 未完成时。建议将 uni.stopPullDownRefresh() 放在异步操作的回调或 Promise 的 finally 块中,确保数据加载完成后再停止刷新动画。例如:

async onPullDownRefresh() {
    this.current = 1;
    this.list1 = [];
    this.list2 = [];
    try {
        await this.geIndex();
    } finally {
        uni.stopPullDownRefresh();
    }
}
回到顶部