Commit 119becb0 authored by 杨奕's avatar 杨奕 Committed by GitHub

Menu: update SubMenu to allow custom component (#10077)

parent 99e5a6b4
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
computed: { computed: {
// popper option // popper option
appendToBody() { appendToBody() {
return this.rootMenu === this.$parent; return this.isFirstLevel;
}, },
menuTransitionName() { menuTransitionName() {
return this.rootMenu.collapse ? 'el-zoom-in-left' : 'el-zoom-in-top'; return this.rootMenu.collapse ? 'el-zoom-in-left' : 'el-zoom-in-top';
...@@ -125,6 +125,19 @@ ...@@ -125,6 +125,19 @@
? this.activeTextColor ? this.activeTextColor
: this.textColor : this.textColor
}; };
},
isFirstLevel() {
let isFirstLevel = true;
let parent = this.$parent;
while (parent && parent !== this.rootMenu) {
if (['ElSubmenu', 'ElMenuItemGroup'].indexOf(parent.$options.componentName) > -1) {
isFirstLevel = false;
break;
} else {
parent = parent.$parent;
}
}
return isFirstLevel;
} }
}, },
methods: { methods: {
...@@ -196,7 +209,7 @@ ...@@ -196,7 +209,7 @@
title && (title.style.backgroundColor = this.rootMenu.backgroundColor || ''); title && (title.style.backgroundColor = this.rootMenu.backgroundColor || '');
}, },
updatePlacement() { updatePlacement() {
this.currentPlacement = this.mode === 'horizontal' && this.rootMenu === this.$parent this.currentPlacement = this.mode === 'horizontal' && this.isFirstLevel
? 'bottom-start' ? 'bottom-start'
: 'right-start'; : 'right-start';
}, },
...@@ -232,7 +245,7 @@ ...@@ -232,7 +245,7 @@
disabled, disabled,
popperClass, popperClass,
$slots, $slots,
$parent isFirstLevel
} = this; } = this;
const popupMenu = ( const popupMenu = (
...@@ -267,7 +280,7 @@ ...@@ -267,7 +280,7 @@
); );
const submenuTitleIcon = ( const submenuTitleIcon = (
rootMenu.mode === 'horizontal' && $parent === rootMenu || rootMenu.mode === 'horizontal' && isFirstLevel ||
rootMenu.mode === 'vertical' && !rootMenu.collapse rootMenu.mode === 'vertical' && !rootMenu.collapse
) ? 'el-icon-arrow-down' : 'el-icon-arrow-right'; ) ? 'el-icon-arrow-down' : 'el-icon-arrow-right';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment