Merge pull request #2872 from lison16/menu

update Menu
This commit is contained in:
Aresn 2018-01-22 13:35:40 +08:00 committed by GitHub
commit 105af4ee57
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 20 deletions

View file

@ -1,6 +1,6 @@
<template>
<div>
<Menu :theme="theme1" active-name="1" accordion @on-select="handleSelect" @on-open-change="handleOpen" :open-names="openArr">
<Menu :theme="theme1" active-name="1" accordion @on-select="handleSelect" @on-open-change="handleOpen" :open-names="openArr">
<Menu-item name="1">
<Icon type="ios-paper"></Icon>
一级1

View file

@ -5,11 +5,12 @@
</li>
</template>
<script>
import { findComponentUpward, findComponentsUpward } from '../../utils/assist';
import mixin from './mixin';
const prefixCls = 'ivu-menu';
export default {
name: 'MenuGroup',
mixins: [ mixin ],
props: {
title: {
type: String,
@ -22,14 +23,8 @@
};
},
computed: {
parentSubmenuNum () {
return findComponentsUpward(this, 'Submenu').length;
},
hasParentSubmenu () {
return findComponentUpward(this, 'Submenu');
},
groupStyle () {
return this.hasParentSubmenu ? {
return this.hasParentSubmenu && this.mode !== 'horizontal' ? {
paddingLeft: 43 + (this.parentSubmenuNum - 1) * 28 + 'px'
} : {};
}

View file

@ -37,7 +37,7 @@
];
},
itemStyle () {
return this.hasParentSubmenu ? {
return this.hasParentSubmenu && this.mode !== 'horizontal' ? {
paddingLeft: 43 + (this.parentSubmenuNum - 1) * 24 + 'px'
} : {};
}

View file

@ -1,11 +1,19 @@
import { findComponentUpward, findComponentsUpward } from '../../utils/assist';
export default {
data () {
return {
menu: findComponentUpward(this, 'Menu')
};
},
computed: {
hasParentSubmenu () {
return findComponentUpward(this, 'Submenu');
},
parentSubmenuNum () {
return findComponentsUpward(this, 'Submenu').length;
},
mode () {
return this.menu.mode;
}
}
};

View file

@ -46,8 +46,7 @@
prefixCls: prefixCls,
active: false,
opened: false,
dropWidth: parseFloat(getStyle(this.$el, 'width')),
parent: findComponentUpward(this, 'Menu')
dropWidth: parseFloat(getStyle(this.$el, 'width'))
};
},
computed: {
@ -63,11 +62,8 @@
}
];
},
mode () {
return this.parent.mode;
},
accordion () {
return this.parent.accordion;
return this.menu.accordion;
},
dropStyle () {
let style = {};
@ -76,7 +72,7 @@
return style;
},
titleStyle () {
return this.hasParentSubmenu ? {
return this.hasParentSubmenu && this.mode !== 'horizontal' ? {
paddingLeft: 43 + (this.parentSubmenuNum - 1) * 24 + 'px'
} : {};
}
@ -88,7 +84,7 @@
clearTimeout(this.timeout);
this.timeout = setTimeout(() => {
this.parent.updateOpenKeys(this.name);
this.menu.updateOpenKeys(this.name);
this.opened = true;
}, 250);
},
@ -98,7 +94,7 @@
clearTimeout(this.timeout);
this.timeout = setTimeout(() => {
this.parent.updateOpenKeys(this.name);
this.menu.updateOpenKeys(this.name);
this.opened = false;
}, 150);
},
@ -112,7 +108,7 @@
});
}
this.opened = !opened;
this.parent.updateOpenKeys(this.name);
this.menu.updateOpenKeys(this.name);
}
},
watch: {