1
0
mirror of https://github.com/PanJiaChen/vue-element-admin.git synced 2025-04-06 03:57:53 +08:00

fix[ImageCropper]: removeEventListener when destroyed(#2169)

This commit is contained in:
MaYuanhai 2019-05-28 15:10:37 +08:00 committed by 花裤衩
parent 9538d1b766
commit a0793dbeab

View File

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