Answer the question
In order to leave comments, you need to log in
How to close modal window with Esc?
There is a modal window template:
template: '\
<div class = "alert"
<button id = "x-button" @click="close">\ // По клику на кнопке работает: модальное окно закрывается
@keypress.enter = "close"\ // А вот с клавиатуры закрытие не работает
@keypress.esc = "close">\
<slot>...</slot>\
</div>\
';
Answer the question
In order to leave comments, you need to log in
Add listeners to the component and do some processing on them:
mounted() {
window.addEventListener('keyup', this.keyup)
},
destroyed() {
window.removeEventListener('keyup', this.keyup)
}
template: '\
<div class = "alert"
@keypress.enter = "close"\
@keypress.esc = "close">\
<button id = "x-button" @click="close">\
<slot>...</slot>\
</div>\
';
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question