mirror of
https://github.com/Hopiu/vue-material.git
synced 2026-05-11 00:33:16 +00:00
Close content on esc
This commit is contained in:
parent
208a47f11e
commit
9893850a7b
2 changed files with 31 additions and 2 deletions
|
|
@ -1,5 +1,22 @@
|
|||
<template>
|
||||
<div class="md-menu-content">
|
||||
<div class="md-menu-content" @keydown.esc="close" tabindex="-1">
|
||||
<slot></slot>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
close() {
|
||||
this.$parent.close();
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.$parent.$el.classList.contains('md-menu')) {
|
||||
this.$destroy();
|
||||
|
||||
throw new Error('You must wrap the md-menu-content in a md-menu');
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<template>
|
||||
<div class="md-menu-item" v-md-ink-ripple @click="$emit('click')">
|
||||
<div class="md-menu-item" @click="close">
|
||||
<div class="md-menu-item-content">
|
||||
<slot></slot>
|
||||
</div>
|
||||
|
|
@ -8,6 +8,18 @@
|
|||
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
close() {
|
||||
this.$emit('click');
|
||||
this.$parent.close();
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (!this.$parent.$el.classList.contains('md-menu-content')) {
|
||||
this.$destroy();
|
||||
|
||||
throw new Error('You must wrap the md-menu-item in a md-menu-content');
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in a new issue