support Menu & Layout
support Menu & Layout
This commit is contained in:
parent
dcbfc23239
commit
fd1582c5b5
10 changed files with 284 additions and 118 deletions
|
@ -2,12 +2,14 @@
|
|||
<li :class="classes" @click.stop="handleClick"><slot></slot></li>
|
||||
</template>
|
||||
<script>
|
||||
import Emitter from '../../mixins/emitter';
|
||||
const prefixCls = 'ivu-menu';
|
||||
|
||||
export default {
|
||||
name: 'MenuItem',
|
||||
mixins: [ Emitter ],
|
||||
props: {
|
||||
key: {
|
||||
name: {
|
||||
type: [String, Number],
|
||||
required: true
|
||||
},
|
||||
|
@ -36,8 +38,30 @@
|
|||
methods: {
|
||||
handleClick () {
|
||||
if (this.disabled) return;
|
||||
this.$dispatch('on-menu-item-select', this.key);
|
||||
|
||||
let parent = this.$parent;
|
||||
let name = parent.$options.name;
|
||||
while (parent && (!name || name !== 'Submenu')) {
|
||||
parent = parent.$parent;
|
||||
if (parent) name = parent.$options.name;
|
||||
}
|
||||
|
||||
if (parent) {
|
||||
this.dispatch('Submenu', 'on-menu-item-select', this.name);
|
||||
} else {
|
||||
this.dispatch('Menu', 'on-menu-item-select', this.name);
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
this.$on('on-update-active-name', (name) => {
|
||||
if (this.name === name) {
|
||||
this.active = true;
|
||||
this.dispatch('Submenu', 'on-update-active-name', true);
|
||||
} else {
|
||||
this.active = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue