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