当前位置:   article > 正文

微信小程序scroll-view下拉刷新_wx scroll-view bindrefresherpulling

wx scroll-view bindrefresherpulling
//wxml
<view class="container">
	<view class="box">
		<scroll-view 
		scroll-y 
		style="width:100%;height:400rpx" 
		refresher-enabled="{{true}}" 
		refresher-threshold="{{100}}" 
		refresher-default-style="white" 
		refresher-background="lightgreen" 
		refresher-triggered="{{triggered}}" 
		bindrefresherpulling="onPulling"
		bindrefresherrefresh="onRefresh" 
		bindrefresherrestore="onRestore" 
		bindrefresherabort="onAbort">
			<view>1</view>
		</scroll-view>
	</view>
</view>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
// js
Page({
  data: {
    triggered: false
  },

  onLoad: function () {
    
  },
  onPulling(e) {//下拉中
    console.log(e, 'pulling')
  },
  onRefresh(e) {//取消下拉
    console.log(e, 'refresh');
    if (this._freshing) return//防止重复下拉
    this._freshing = true
    setTimeout(() => {//下拉请求完成
      this.setData({
        triggered: false,
      })
      this._freshing = false
    }, 3000)
  },
  onRestore(e) {//复位
    console.log(e, 'restore')
  },
  onAbort(e) {//没有下拉到refresher-threshold值
    console.log(e, 'abort')
  }
})

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/221183
推荐阅读