better-score獲取滑動距離的坑


this.contentScroll = new BScroll(this.$refs.contentWrap,{
            probeType:3,//探針,獲取滑動距離必備
            click:true
});

//然后通過
this.contentScroll.on('scroll',(pos)=>{
          this.scrollY = Math.abs(Math.round(pos.y));
});
//但在vue中有個奇怪的坑
//如果不這樣做,獲取的滑動距離始終為0?
if(this.contentScroll){
          this.contentScroll.refresh();
        }else {
          this.contentScroll = new BScroll(this.$refs.contentWrap,{
            probeType:3,
            click:true
          });
}
//好吧,我明白了,是這行代碼造的坑
this.contentScroll.refresh();//此處寫在重置中

  


免責聲明!

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



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