fix: waves failed after adding handler

当用户给一个元素(如按钮元素)添加v-waves指令后,如果用户再给元素添加一个click事件handler,而这个handler在执行时触发了组件的update,那么按钮的波动效果就会失效。
This commit is contained in:
Beck Xun 2020-08-29 08:26:53 +08:00 committed by GitHub
parent 5e7113935c
commit d0ea7c5de2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

View File

@ -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) {