From d0ea7c5de2e9dc6300e7a5c66c418cd842c1b9c9 Mon Sep 17 00:00:00 2001 From: Beck Xun Date: Sat, 29 Aug 2020 08:26:53 +0800 Subject: [PATCH] fix: waves failed after adding handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当用户给一个元素(如按钮元素)添加v-waves指令后,如果用户再给元素添加一个click事件handler,而这个handler在执行时触发了组件的update,那么按钮的波动效果就会失效。 --- src/directive/waves/waves.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/directive/waves/waves.js b/src/directive/waves/waves.js index ec2ff439..8ac0ff7f 100644 --- a/src/directive/waves/waves.js +++ b/src/directive/waves/waves.js @@ -61,7 +61,10 @@ export default { el.addEventListener('click', handleClick(el, binding), false) }, update(el, binding) { - el.removeEventListener('click', el[context].removeHandle, false) + const removeHandler = el[context].removeHandle + setTimeout(_ => { + el.removeEventListener('click', removeHandler, false) + }) el.addEventListener('click', handleClick(el, binding), false) }, unbind(el) {