2016-10-19 23:33:31 +00:00
|
|
|
<template>
|
2016-10-25 00:04:00 +00:00
|
|
|
<div
|
|
|
|
|
class="md-menu-item"
|
|
|
|
|
:class="classes"
|
|
|
|
|
@click="close">
|
2016-10-19 23:33:31 +00:00
|
|
|
<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-19 23:33:31 +00:00
|
|
|
|
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
|
|
|
}
|
2016-10-19 23:33:31 +00:00
|
|
|
};
|
|
|
|
|
</script>
|