mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-21 18:24:26 +08:00
automatically close dialog when press esc in keyboard or back button in mobile device
This commit is contained in:
@@ -79,4 +79,21 @@ new Vue({
|
|||||||
el: '#app',
|
el: '#app',
|
||||||
i18n: i18n,
|
i18n: i18n,
|
||||||
render: h => h(App),
|
render: h => h(App),
|
||||||
|
mounted: function () {
|
||||||
|
const app = this.$f7;
|
||||||
|
|
||||||
|
window.addEventListener('popstate', () => {
|
||||||
|
if (document.querySelectorAll('.modal-in').length > 0) {
|
||||||
|
app.dialog.close();
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
document.addEventListener('keydown', (event) => {
|
||||||
|
if (event.key === 'Escape' || event.key === 'Esc' || event.keyCode === 27 || event.which === 27) {
|
||||||
|
if (document.querySelectorAll('.modal-in').length > 0) {
|
||||||
|
app.dialog.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user