From 291feaebe88ca3467c62734bef6c735a5219079f Mon Sep 17 00:00:00 2001 From: zsir Date: Fri, 6 Mar 2020 15:48:58 +0800 Subject: [PATCH] =?UTF-8?q?fix(taro-components):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=AE=9A=E6=97=B6=E5=99=A8=E5=9C=A8=E7=BB=84=E4=BB=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E6=97=B6=E6=9C=AA=E5=8F=96=E6=B6=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-components/src/components/button/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/taro-components/src/components/button/index.js b/packages/taro-components/src/components/button/index.js index 14daab697580..22654976acaf 100644 --- a/packages/taro-components/src/components/button/index.js +++ b/packages/taro-components/src/components/button/index.js @@ -13,6 +13,11 @@ class Button extends Nerv.Component { touch: false } } + + componentWillUnmount() { + this.startTimer && clearTimeout(this.startTimer) + this.endTimer && clearTimeout(this.endTimer) + } render () { const { @@ -48,7 +53,7 @@ class Button extends Nerv.Component { touch: true })) if (hoverClass && hoverClass !== 'none' && !disabled) { - setTimeout(() => { + this.startTimer = setTimeout(() => { if (this.state.touch) { this.setState(() => ({ hover: true @@ -63,7 +68,7 @@ class Button extends Nerv.Component { touch: false })) if (hoverClass && hoverClass !== 'none' && !disabled) { - setTimeout(() => { + this.endTimer = setTimeout(() => { if (!this.state.touch) { this.setState(() => ({ hover: false