refThrottled
参考值的节流变化。
¥Throttle changing of a ref value.
示例
Delay is set to 1000ms for this demo.
Throttled:
Times Updated: 0
Trailing: true
Leading: false
用法
¥Usage
js
import { refThrottled } from '@vueuse/core'
import { shallowRef } from 'vue'
const input = shallowRef('')
const throttled = refThrottled(input, 1000)
尾随
¥Trailing
如果你不想查看跟踪更改,请设置第三个参数 false
(默认为 true
):
¥If you don't want to watch trailing changes, set 3rd param false
(it's true
by default):
js
import { refThrottled } from '@vueuse/core'
import { shallowRef } from 'vue'
const input = shallowRef('')
const throttled = refThrottled(input, 1000, false)
领导
¥Leading
允许立即调用回调(在 ms
超时的前沿)。如果你不希望出现此行为,请设置第四个参数 false
(默认为 true
):
¥Allows the callback to be invoked immediately (on the leading edge of the ms
timeout). If you don't want this behavior, set the 4th param false
(it's true
by default):
js
import { refThrottled } from '@vueuse/core'
import { shallowRef } from 'vue'
const input = shallowRef('')
const throttled = refThrottled(input, 1000, undefined, false)
推荐阅读
¥Recommended Reading