/* 截流函数 */
export function throttle(func: Function) {
let start = 0
return function (delay = 1000) {
/* 通过+号可以转化成时间戳 */
let now = +new Date()
now - start > delay ? (start = now) : func()
}
}
10-06
2202
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
07-30
220
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-22
374
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-21
374
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
08-23
841
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)