From 289a47be8fa7a0fccdb4a0074e98c90217c45882 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Mon, 13 Jul 2020 13:46:00 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20bug:=20fix=20hideChildrenInMenu?= =?UTF-8?q?=20no=20work=20for=20menuItemRender=20(#556)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/SiderMenu/BaseMenu.tsx | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/SiderMenu/BaseMenu.tsx b/src/SiderMenu/BaseMenu.tsx index 045714bb..803a483d 100644 --- a/src/SiderMenu/BaseMenu.tsx +++ b/src/SiderMenu/BaseMenu.tsx @@ -205,17 +205,19 @@ class MenuUtil { } if (menuItemRender) { - return menuItemRender( - { - ...item, - isUrl: isHttpUrl, - itemPath, - isMobile, - replace: itemPath === location.pathname, - onClick: () => onCollapse && onCollapse(true), - }, - defaultItem, - ); + const renderItemProps = { + ...item, + isUrl: isHttpUrl, + itemPath, + isMobile, + replace: itemPath === location.pathname, + onClick: () => onCollapse && onCollapse(true), + }; + // 如果 hideChildrenInMenu 删除掉无用的 children + if (renderItemProps.hideChildrenInMenu) { + delete renderItemProps.children; + } + return menuItemRender(renderItemProps, defaultItem); } return defaultItem; };