From 6cf1a3b70ed2b14f221c542996963270f9633349 Mon Sep 17 00:00:00 2001 From: Lindy <33708359+Lindysen@users.noreply.github.com> Date: Tue, 17 Mar 2020 20:22:16 +0800 Subject: [PATCH] fix(Button): disabled button does not emit event handler (#2878) --- packages/button/index.ts | 2 +- packages/button/index.wxml | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/button/index.ts b/packages/button/index.ts index a3dfefa4..e1abc1d9 100644 --- a/packages/button/index.ts +++ b/packages/button/index.ts @@ -68,7 +68,7 @@ VantComponent({ methods: { onClick() { - if (!this.data.disabled && !this.data.loading) { + if (!this.data.loading) { this.$emit('click'); } } diff --git a/packages/button/index.wxml b/packages/button/index.wxml index 3239354f..8429d2fb 100644 --- a/packages/button/index.wxml +++ b/packages/button/index.wxml @@ -15,13 +15,13 @@ show-message-card="{{ showMessageCard }}" app-parameter="{{ appParameter }}" aria-label="{{ ariaLabel }}" - bindtap="onClick" - bindgetuserinfo="bindGetUserInfo" - bindcontact="bindContact" - bindgetphonenumber="bindGetPhoneNumber" - binderror="bindError" - bindlaunchapp="bindLaunchApp" - bindopensetting="bindOpenSetting" + bindtap="{{ !disabled ? onClick : null }}" + bindgetuserinfo="{{ !disabled ? bindGetUserInfo : null }}" + bindcontact="{{ !disabled ? bindContact : null }}" + bindgetphonenumber="{{ !disabled ? bindGetPhoneNumber : null }}" + binderror="{{ !disabled ? bindError : null }}" + bindlaunchapp="{{ !disabled ? bindLaunchApp : null}}" + bindopensetting="{{ !disabled ? bindOpenSetting : null }}" >