舒大少博客

一个95后少年的个人博客

当前时间为:
欢迎大家来到舒大少博客https://www.9713job.com,广告合作以及淘宝商家推广请微信联系15357240395

微信小程序之下拉刷新及上拉触底事件

2022-04-22 10:03:54
swq1822677238

手机扫码查看

微信小程序之下拉刷新及上拉触底事件
  1. 监听页面的下拉刷新事件
    在页面的.js 文件中,通过 onPullDownRefresh() 函数即可监听当前页面的下拉刷新事件
  2. 停止下拉刷新事件
    当处理完下拉刷新后,下拉刷新的 loading 效果会一直显示,不会主动消失。
    调用wx.stopPullDownRefresh() 可以停止当前页面的下拉刷新
  3. 监听上拉触底事件
    在页面的.js 文件中,通过 onReachBottom() 函数即可监听当前页面的上拉触底事件
  4. 添加loading效果
  5. 对上拉触底进行节流处理

    data:{
    isLoding:false
    }
    getColor:{
    this.setData({
    isLoding:true
    })
    wx.request(){
    success下面
    complete:()=>{
    wx.hideLoading()
    this.setData({
    isLoding:false
    })
    }
    }
    }
    onReachBottom:function(){
    if(this.data.isLoading) return
    this.getColors()
    }

发表评论

邮箱地址不会被公开。 必填项已用*标注