Skip to content

Commit

Permalink
destroyed移除监听
Browse files Browse the repository at this point in the history
  • Loading branch information
马云海 mayunhai () committed May 28, 2019
1 parent 9538d1b commit e7a4056
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/components/ImageCropper/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down

0 comments on commit e7a4056

Please sign in to comment.