update Menu

This commit is contained in:
梁灏 2018-07-01 11:37:30 +08:00
parent f9a6a467a6
commit 2a7765f93d
2 changed files with 23 additions and 10 deletions

View file

@ -102,7 +102,7 @@
},
methods: {
// Ctrl or CMD and click, open in new window when use `to`
handleClickLink (event, new_window) {
handleClickLink (event, new_window = false) {
this.$emit('click', event);
this.handleCheckClick(event, new_window);

View file

@ -1,5 +1,13 @@
<template>
<a v-if="to" :href="linkUrl" :target="target" :class="classes" @click="handleClickItem" :style="itemStyle"><slot></slot></a>
<a
v-if="to"
:href="linkUrl"
:target="target"
:class="classes"
@click.exact="handleClickItem($event, false)"
@click.ctrl="handleClickItem($event, true)"
@click.meta="handleClickItem($event, true)"
:style="itemStyle"><slot></slot></a>
<li v-else :class="classes" @click.stop="handleClickItem" :style="itemStyle"><slot></slot></li>
</template>
<script>
@ -46,18 +54,23 @@
}
},
methods: {
handleClickItem (event) {
handleClickItem (event, new_window = false) {
if (this.disabled) return;
let parent = findComponentUpward(this, 'Submenu');
if (parent) {
this.dispatch('Submenu', 'on-menu-item-select', this.name);
if (new_window) {
// new_window
this.handleCheckClick(event, new_window);
} else {
this.dispatch('Menu', 'on-menu-item-select', this.name);
}
let parent = findComponentUpward(this, 'Submenu');
this.handleCheckClick(event);
if (parent) {
this.dispatch('Submenu', 'on-menu-item-select', this.name);
} else {
this.dispatch('Menu', 'on-menu-item-select', this.name);
}
this.handleCheckClick(event, new_window);
}
}
},
mounted () {