You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.1 KiB
43 lines
1.1 KiB
5 years ago
|
import { SubMenu as VcSubMenu } from '../vc-menu';
|
||
|
import { getListeners } from '../_util/props-util';
|
||
|
import classNames from 'classnames';
|
||
|
|
||
|
export default {
|
||
|
name: 'ASubMenu',
|
||
|
isSubMenu: true,
|
||
|
props: { ...VcSubMenu.props },
|
||
|
inject: {
|
||
|
menuPropsContext: { default: () => ({}) },
|
||
|
},
|
||
|
methods: {
|
||
|
onKeyDown(e) {
|
||
|
this.$refs.subMenu.onKeyDown(e);
|
||
|
},
|
||
|
},
|
||
|
|
||
|
render() {
|
||
|
const { $slots, $scopedSlots } = this;
|
||
|
const { rootPrefixCls, popupClassName } = this.$props;
|
||
|
const { theme: antdMenuTheme } = this.menuPropsContext;
|
||
|
const props = {
|
||
|
props: {
|
||
|
...this.$props,
|
||
|
popupClassName: classNames(`${rootPrefixCls}-${antdMenuTheme}`, popupClassName),
|
||
|
},
|
||
|
ref: 'subMenu',
|
||
|
on: getListeners(this),
|
||
|
scopedSlots: $scopedSlots,
|
||
|
};
|
||
|
const slotsKey = Object.keys($slots);
|
||
|
return (
|
||
|
<VcSubMenu {...props}>
|
||
|
{slotsKey.length
|
||
|
? slotsKey.map(name => {
|
||
|
return <template slot={name}>{$slots[name]}</template>;
|
||
|
})
|
||
|
: null}
|
||
|
</VcSubMenu>
|
||
|
);
|
||
|
},
|
||
|
};
|