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();//此处写在重置中

  

原文地址:https://www.cnblogs.com/zhoujx1066/p/6814599.html