vue 解決滾動與下拉刷新沖突


1.思路

監聽滾動條與頂部的距離,當距離不為0時,禁用下拉刷新。即滾動條在頂部時啟用下拉刷新,不在頂部禁用下拉刷新。

2.代碼實現

    <van-pull-refresh style="height:100%" v-model="isLoading" @refresh="onRefresh" :disabled="refDisabled" >
      <van-tabs v-model="active">
        <van-tab title="xxx">
          <div class="carspace_con" id="carspace_con" ref="Box" @scroll="divScroll">
                        
          </div>
        </van-tab>
        <van-tab title="yyy">
          
        </van-tab>
        
      </van-tabs>
    </van-pull-refresh>

 

divScroll(e){
      let toTop = this.$refs.Box.scrollTop;
      //console.log('距離頂部'+toTop);
      if(toTop==0){
        this.refDisabled=false
      }
      else{
        this.refDisabled=true;
      }

    },

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM