vue-material/src/components/mdMenu/mdMenuItem.vue

44 lines
815 B
Vue
Raw Normal View History

<template>
2016-10-25 00:04:00 +00:00
<div
class="md-menu-item"
:class="classes"
@click="close">
<div class="md-menu-item-content">
<slot></slot>
</div>
</div>
</template>
<script>
export default {
2016-10-25 00:04:00 +00:00
data() {
return {
index: 0
};
},
computed: {
classes() {
return {
'md-highlighted': this.index === this.$parent.highlighted
};
}
},
2016-10-24 23:26:26 +00:00
methods: {
close() {
this.$emit('click');
this.$parent.close();
}
},
mounted() {
if (!this.$parent.$el.classList.contains('md-menu-content')) {
this.$destroy();
2016-10-24 23:26:26 +00:00
throw new Error('You must wrap the md-menu-item in a md-menu-content');
}
2016-10-25 00:04:00 +00:00
this.$parent.itemsAmount++;
this.index = this.$parent.itemsAmount;
2016-10-24 23:26:26 +00:00
}
};
</script>