為何捐款
API 瀏覽器
Directive v-scroll

這是一個 Vue 指令,它接受一個參數(一個函式),並在使用者捲動包含該 DOM 節點的頁面時觸發。

提示

  • 使用此指令的一個替代方案是在您的頁面上放置一個 QScrollObserver 元件。
  • 還有另一個與捲動相關的指令可用,稱為 Scroll Fire
載入捲動 API...

用法

<template>
  ...
  <div v-scroll="onScroll">...</div>
  ...
</template>

<script>
export default {
  setup () {
    function onScroll (position) {
      // when this method is invoked then it means user
      // has scrolled the page to `position`
      //
      // `position` is an Integer designating the current
      // scroll position in pixels.
    }

    return { onScroll }
  }
}
</script>
import { debounce } from 'quasar'

export default {
  setup () {
    function onScroll (position) {
      // when this method is invoked then it means user
      // has scrolled the page to `position`
      //
      // `position` is an Integer designating the current
      // scroll position in pixels.
    }

    return {
      onScroll: debounce(onScroll, 200) // debounce for 200ms
    }
  }
}

判斷捲動容器

這裡閱讀關於 Quasar 如何判斷要附加捲動事件的容器。