From 0a7065ce8930a6dcc910868bac821632c97b03a1 Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Sun, 25 Oct 2020 23:05:29 +0800 Subject: [PATCH] fix: menu error --- components/vc-menu/MenuItemGroup.jsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/components/vc-menu/MenuItemGroup.jsx b/components/vc-menu/MenuItemGroup.jsx index b4bb3f46f..2a1bf74e2 100644 --- a/components/vc-menu/MenuItemGroup.jsx +++ b/components/vc-menu/MenuItemGroup.jsx @@ -1,11 +1,17 @@ import PropTypes from '../_util/vue-types'; import { getComponent, getSlot } from '../_util/props-util'; import { menuAllProps } from './util'; -import { defineComponent } from 'vue'; - +import { defineComponent, inject } from 'vue'; +import classNames from '../_util/classNames'; +const injectExtraPropsKey = 'ANT_MENU_PROVIDER_PROPS_KEY'; const MenuItemGroup = { name: 'MenuItemGroup', inheritAttrs: false, + setup() { + return { + injectExtraProps: inject(injectExtraPropsKey, () => ({})), + }; + }, props: { renderMenuItem: PropTypes.func, index: PropTypes.number, @@ -18,12 +24,12 @@ const MenuItemGroup = { isMenuItemGroup: true, methods: { renderInnerMenuItem(item) { - const { renderMenuItem, index, subMenuKey } = this.$props; + const { renderMenuItem, index, subMenuKey } = { ...this.$props, ...this.injectExtraProps }; return renderMenuItem(item, index, subMenuKey); }, }, render() { - const props = { ...this.$props, ...this.$attrs }; + const props = { ...this.$props, ...this.injectExtraProps, ...this.$attrs }; const { class: cls = '', rootPrefixCls, title } = props; const titleClassName = `${rootPrefixCls}-item-group-title`; const listClassName = `${rootPrefixCls}-item-group-list`; @@ -32,7 +38,7 @@ const MenuItemGroup = { delete props.onClick; const children = getSlot(this); return ( -
  • +
  • {getComponent(this, 'title')}