fixed the bug about styles when mode is 'horizontal' of menu

This commit is contained in:
zhigang.li 2018-01-22 13:12:15 +08:00
parent 6b4e738352
commit b2d676bd83
5 changed files with 28 additions and 14 deletions

View file

@ -25,7 +25,7 @@
},
computed: {
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 = {};
@ -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: {