防止重复点击
/** * 防止重覆点击 * @param timer callBack * @returns 自执行函数 */ declare global { interface Window { lastTime: any } } export const preventCliks = (callBack: Function, timer: number = 500): void => { const _lastTime = window.lastTime || 0 return ((): void => { const nowTime = +new Date() if (nowTime - _lastTime > timer || !_lastTime) { window.lastTime = nowTime callBack() } })() }