yangan
2024-02-05 fb20d356a9d1415816102a2610af383feaea5d3b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
export function todayDate(arg) {
    let date = new Date()
    let year = date.getFullYear()
    let month = date.getMonth() + 1;
    let day = date.getDate()
    let hour = date.getHours()
    let minutes = date.getMinutes()
    let seconds = date.getSeconds()
    if (arg == 'hms') {
        hour = hour < 10 ? '0' + hour : hour
        minutes = minutes < 10 ? '0' + minutes : minutes
        seconds = seconds < 10 ? '0' + seconds : seconds
        return hour + ':' + minutes + ':' + seconds
    }
}
 
export const Debounce = (fn, wait) => {
    let delay = wait|| 500
    let timer
    return function () {
        let args = arguments;
        if (timer) {
            clearTimeout(timer)
        }
 
        let callNow = !timer
 
        timer = setTimeout(() => {
            timer = null
        }, delay)
 
        if (callNow) fn.apply(this, args)
    }
}