From 45bb712e33986cf77a23a95d04405f7603e8f021 Mon Sep 17 00:00:00 2001 From: songsy Date: Tue, 6 Dec 2022 12:58:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E9=98=B2=E6=8A=96=E6=8C=87=E4=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/directive/index.ts | 1 + src/directive/utils/index.ts | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 src/directive/utils/index.ts diff --git a/src/directive/index.ts b/src/directive/index.ts index 39edd276..a9663760 100644 --- a/src/directive/index.ts +++ b/src/directive/index.ts @@ -1 +1,2 @@ export { hasPerm, hasRole } from './permission'; +export { deBounce } from './utils'; diff --git a/src/directive/utils/index.ts b/src/directive/utils/index.ts new file mode 100644 index 00000000..651247f8 --- /dev/null +++ b/src/directive/utils/index.ts @@ -0,0 +1,15 @@ +import { Directive, DirectiveBinding } from 'vue'; + +/** + * 按钮防抖 + */ +export const deBounce:Directive = { + mounted(el:HTMLElement) { + el.addEventListener('click', e => { + el.classList.add('is-disabled') + setTimeout(() => { + el.classList.remove('is-disabled') + }, 2000) + }) + } +} -- Gitee