vue 滚动插件BetterScroll属性事件

当前版本

"better-scroll": "^2.4.1",

scroll事件
滚动的实时坐标(与probeType属性有关)

<script>
  import BetterScroll from 'better-scroll'

  export default {
    name: 'HelloWorld',
    mounted() {
      const bs = new BetterScroll('.hello', {
        probeType: 2
      })

      bs.on('scroll', (pos) => {
        console.log(pos);
      })

      bs.on('scrollEnd', () => {
        console.log("scrollEnd");
      })
    }
  }
</script>

probeType属性
默认值:0
可选值:1、2、3
当 probeType 为 1 的时候,会非实时(屏幕滑动超过一定时间后)派发scroll 事件;
当 probeType 为 2 的时候,会在屏幕滑动的过程中实时的派发 scroll 事件;
当 probeType 为 3 的时候,不仅在屏幕滑动的过程中,而且在 momentum 滚动动画运行过程中实时派发 scroll 事件。
如果没有设置该值,其默认值为 0,即不派发 scroll 事件

image

posted @ 2021-07-20 19:17  thomas_blog  阅读(220)  评论(0编辑  收藏  举报