debounceDtor【去抖装饰器】
描述
截流装饰器
# 1.示例
复制代码
# 2.入参说明
| 参数 | 说明 | 类型 | 是否必填 | 默认值 |
|---|---|---|---|---|
| wait | 去抖时间 | Number | 300 |
# 3.源码
import debounce from '@/function/debounce'
/**
* 函数节流装饰器
* @param {number} wait 节流的毫秒
* @param {Object|Boolean} options 参数{leading: 是否在之前执行, trailing: 是否在之后执行} 默认在定时器之后执行 trailing = true
*/
function debounceDtor(wait = 300, options) {
return function (target, name, descriptor) {
descriptor.value = debounce(descriptor.value, wait, options)
}
}
export default debounceDtor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
上次更新: 2023/06/24, 19:35:48