Signed-off-by: chy <chy@163.com>

This commit is contained in:
chy
2026-02-02 23:28:29 +08:00
commit 84bdfdb8bc
576 changed files with 941155 additions and 0 deletions

27
src/utils/throttle.js Normal file
View File

@@ -0,0 +1,27 @@
/*
* @Descripttion:
* @version:
* @Author: qianlishi
* @Date: 2021-12-11 14:48:27
* @LastEditors: qianlishi
* @LastEditTime: 2021-12-13 10:16:48
*/
/**
* 函数节流
*/
export function _throttle(fn,delay){
let timer
let delay = delay || 1000; //一秒内触发一次
return function(...args){
const context = this
let canExecute = !timer
if(canExecute){
fn.apply(context,args)
}else{
clearTimeout(timer)
}
timer = setTimeout(() => {
timer = null
}, delay);
}
}