Your Name
2022-06-29 a266ece06a2a4c906e5377d3417962fa3760aef6
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
import { App } from 'vue'
 
export function preventClick(app: App){
    app.directive('debounce', {
        mounted(el, binding) {
            let timer : NodeJS.Timeout | null = null
            el.addEventListener('click', () => {
                debugger
                let firstClick: Boolean = !timer;
                if(firstClick){
                    binding.value
                }
                if(timer){
                    clearTimeout(timer)
                }
                timer = setTimeout(() => {
                    timer = null
                    if(!firstClick){
                        binding.value
                    }
                },3000);
            })
        }
    })
}