當前位置:網站首頁>scroll-view實現下拉刷新(避免onload進入頁面初始refresher-triggered為true觸發下拉問題)

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

2022-07-24 00:53:25路光.

避免初始進入頁面由於要將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://cht.chowdera.com/2022/205/202207240052450680.html

隨機推薦