debounce 函数用于防抖处理,在指定时间内多次触发只执行最后一次。
import { debounce } from '@movk/core'
const debouncedSearch = debounce((query: string) => {
console.log('搜索:', query)
}, 300)
// 连续调用,只有最后一次会执行
debouncedSearch('a')
debouncedSearch('ab')
debouncedSearch('abc') // 只有这次会在300ms后执行
debounce<T>(func, wait)防抖函数,在指定时间内多次触发只执行最后一次。
7c832 — refactor!: 重构模块架构,拆分 utils 为专业化模块