fix[ImageCropper]: removeEventListener when destroyed(#2169)
This commit is contained in:
parent
884587cccf
commit
440b5c6596
|
@ -839,16 +839,20 @@ export default {
|
|||
that.$emit('crop-upload-fail', err, field, ki)
|
||||
}
|
||||
})
|
||||
},
|
||||
closeHandler(e) {
|
||||
if (this.value && (e.key == 'Escape' || e.keyCode == 27)) {
|
||||
this.off()
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// 绑定按键esc隐藏此插件事件
|
||||
document.addEventListener('keyup', (e) => {
|
||||
if (this.value && (e.key == 'Escape' || e.keyCode == 27)) {
|
||||
this.off()
|
||||
}
|
||||
})
|
||||
}
|
||||
document.addEventListener('keyup', this.closeHandler)
|
||||
},
|
||||
destroyed() {
|
||||
document.removeEventListener('keyup', this.closeHandler)
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
Loading…
Reference in New Issue