chore(防抖节流工具): 新增注释

This commit is contained in:
hzj 2026-03-09 15:06:59 +08:00
parent a565442c60
commit 7a0aa39d5d

View File

@ -1,6 +1,6 @@
import { getCurrentInstance, onUnmounted } from 'vue'
// 防抖
// 防抖(仅在最新一次请求的计时结束后执行)
export function useDebounce(fn, delay = 500, immediate = false) {
let timer = null
let instance = getCurrentInstance() // 获取当前组件实例
@ -42,7 +42,7 @@ export function useDebounce(fn, delay = 500, immediate = false) {
return debounced
}
// 节流
// 节流(执行第一次请求,直到计时器结束,才可以重新请求)
export function useThrottle(fn, delay = 1000) {
let lastCall = 0