menu-group.vue
1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<template>
<li :class="[prefixCls + '-item-group']">
<div :class="[prefixCls + '-item-group-title']" :style="groupStyle">{{ title }}</div>
<ul><slot></slot></ul>
</li>
</template>
<script>
import { findComponentUpward, findComponentsUpward } from '../../utils/assist';
const prefixCls = 'ivu-menu';
export default {
name: 'MenuGroup',
props: {
title: {
type: String,
default: ''
}
},
data () {
return {
prefixCls: prefixCls
};
},
computed: {
parentSubmenuNum () {
return findComponentsUpward(this, 'Submenu').length;
},
hasParentSubmenu () {
return findComponentUpward(this, 'Submenu');
},
groupStyle () {
return this.hasParentSubmenu ? {
paddingLeft: 43 + (this.parentSubmenuNum - 1) * 28 + 'px'
} : {};
}
}
};
</script>