debounce.js
import Vue from "vue" Vue.directive("debounce", { inserted: function (el, binding) { let timer el.addEventListener('click', () => { if (timer) { clearTimeout(timer) } timer = setTimeout(() => { binding.value() }, 1000) }) }, })
2023-11-10 22:05:10
debounce.js
import Vue from "vue" Vue.directive("debounce", { inserted: function (el, binding) { let timer el.addEventListener('click', () => { if (timer) { clearTimeout(timer) } timer = setTimeout(() => { binding.value() }, 1000) }) }, })
下一篇:2021-10-21