throttleDtor【截流装饰器】
描述
截流装饰器
# 1.示例
复制代码
# 2.入参说明
| 参数 | 说明 | 类型 | 是否必填 | 默认值 |
|---|---|---|---|---|
| wait | 截流时间 | Number | 20 |
# 3.源码
import throttle from '@/function/throttle'
/**
* 函数防抖装饰器
* @param {number} wait 需要延迟的毫秒数。
* @param {Object} options 参数{leading: 是否在之前执行, trailing: 是否在之后执行} 默认在定时器之前执行 leading = true
*/
function throttleDtor(wait = 20, options) {
return function (target, name, descriptor) {
descriptor.value = throttle(descriptor.value, wait, options)
}
}
export default throttleDtor
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