You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.3 KiB
49 lines
1.3 KiB
/*
|
|
* @Author: ch
|
|
* @Date: 2022-03-17 19:15:10
|
|
* @LastEditors: ch
|
|
* @LastEditTime: 2022-05-23 11:40:29
|
|
* @Description: 一些无法归类的公共方法容器
|
|
*/
|
|
|
|
import {
|
|
toAsyncAwait as ToAsyncAwait,
|
|
isPhone as IsPhone,
|
|
formatDate as FormatDate,
|
|
creatUuid as CreateUUID,
|
|
formatSearchJson as FormatSearchJson
|
|
|
|
} from "js-util-all";
|
|
|
|
/** 防抖函数
|
|
* 首次运行时把定时器赋值给一个变量, 第二次执行时,
|
|
* 如果间隔没超过定时器设定的时间则会清除掉定时器,
|
|
* 重新设定定时器, 依次反复, 当我们停止下来时,
|
|
* 没有执行清除定时器, 超过一定时间后触发回调函数。
|
|
*/
|
|
const Debounce = (fn, delay) => {
|
|
let timer
|
|
return function() {
|
|
const that = this
|
|
const _args = arguments // 存一下传入的参数
|
|
if (timer) {
|
|
clearTimeout(timer)
|
|
}
|
|
timer = setTimeout(function() {
|
|
fn.apply(that, _args)
|
|
}, delay)
|
|
}
|
|
}
|
|
// 工具类的文件需要把文件提供的工具类统一放最下方做一个统一输出
|
|
export {
|
|
// async await 标识结果处理
|
|
ToAsyncAwait,
|
|
// 判断是否为手机号
|
|
IsPhone,
|
|
// 时间格式化
|
|
FormatDate,
|
|
FormatSearchJson,
|
|
CreateUUID,
|
|
// 防抖函数
|
|
Debounce
|
|
} |