scroll-view實現下拉刷新(避免onload進入頁面初始refresher-triggered為true觸發下拉問題)

路光. 2022-07-24 00:53:25 阅读数:163

scroll-viewscrollview下拉刷新
避免初始進入頁面由於要將refresher-triggered為true才可正常使用下拉加載問題
<scroll-view scroll-y="true" :style="{height:scrollH+'px'}"
:refresher-triggered="triggered" @scrolltolower="scrolltolower"
:refresher-threshold="100"
@refresherrefresh="onRefresh" @refresherrestore="onRestore"
@refresherabort="onAbort" refresher-background="linear-gradient( to right, #A0AAFF,#5E6EFF)"
@refresherpulling="refreshPullingTap" :refresher-enabled="isRefresher">
<view></view>
</scroll-view>
data(){
return{
scrollH:0,
triggered:false,
_freshing:false,
isRefresher:true
}
},
methods:{
scrolltolower(e){
uni.$u.throttle(this.commonPage(), 1000)
},
onRefresh(){
if (this._freshing) return;
this._freshing = true;
this.findRecruitNewsList(0);
let tName=setTimeout(()=>{
clearTimeout(tName)
this.triggered = false;
this._freshing = false;
},1000)
},
onRestore(){
this.triggered = 'restore';
},
onAbort(){
},
refreshPullingTap(){
},
}

關鍵代碼:

onLoad(){

     //設置一個控制開啟自定義下拉刷新開關

     this.isRefresher=false;

     let t=setTimeout(() => {

          clearTimeout(t);

          this.triggered = true;  

     }, 1000)

     let ts=setTimeout(()=>{

          clearTimeout(ts);

          this.isRefresher=true;

     },3000)

},  

版权声明:本文为[路光.]所创,转载请带上原文链接,感谢。 https://gsmany.com/2022/205/202207240052450680.html