From ebb04518d1e95f25e735dab341ba1275d20cf236 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Thu, 3 Jun 2021 14:13:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dbutton=E7=9A=84=E4=BA=8B?= =?UTF-8?q?=E4=BB=B6=E6=8B=A6=E6=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/form/button.wc | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/src/form/button.wc b/src/form/button.wc index 4710fcd..be3f5ab 100644 --- a/src/form/button.wc +++ b/src/form/button.wc @@ -341,19 +341,24 @@ export default class Button { this.stamp = 0 // 阻止事件冒泡, 避免用户自己绑定click事件不受这2个值的限制 - this._handleClick = $.catch(this, 'click', ev => { - var { loading, disabled, lazy } = this.props - var now = Date.now() + this._handleClick = $.bind( + this, + 'click', + ev => { + var { loading, disabled, lazy } = this.props + var now = Date.now() - if (loading || disabled) { - return ev.preventDefault() - } - // 并发拦截 - if (lazy && now - this.stamp < lazy) { - return ev.preventDefault() - } - this.stamp = now - }) + if (loading || disabled) { + return ev.stopPropagation() + } + // 并发拦截 + if (lazy && now - this.stamp < lazy) { + return ev.stopPropagation() + } + this.stamp = now + }, + true + ) } unmounted() {