From 1c63757d55076d15ffdf21d647de393ca3c6b0be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E8=B4=A2=E5=AF=8C?= <1501583478@qq.com> Date: Mon, 18 Dec 2023 16:47:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Menu=E8=8F=9C=E5=8D=95=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BAbug=EF=BC=8CrenderMenuItem=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=9A=84=E6=95=B0=E7=BB=84=E5=AD=98=E5=9C=A8undefined=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=EF=BC=8C=E5=AF=BC=E8=87=B4=E7=9C=81=E7=95=A5=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E6=98=BE=E7=A4=BA=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Menu/src/components/useRenderMenuItem.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/components/Menu/src/components/useRenderMenuItem.tsx b/src/components/Menu/src/components/useRenderMenuItem.tsx index d7fede2c3..3a3392233 100644 --- a/src/components/Menu/src/components/useRenderMenuItem.tsx +++ b/src/components/Menu/src/components/useRenderMenuItem.tsx @@ -12,9 +12,10 @@ export const useRenderMenuItem = ( menuMode: 'vertical' | 'horizontal' ) => { const renderMenuItem = (routers: AppRouteRecordRaw[], parentPath = '/') => { - return routers.map((v) => { - const meta = v.meta ?? {} - if (!meta.hidden) { + return routers + .filter((v) => !v.meta?.hidden) + .map((v) => { + const meta = v.meta ?? {} const { oneShowingChild, onlyOneChild } = hasOneShowingChild(v.children, v) const fullPath = isUrl(v.path) ? v.path : pathResolve(parentPath, v.path) // getAllParentPath(allRouters, v.path).join('/') @@ -48,8 +49,7 @@ export const useRenderMenuItem = ( ) } - } - }) + }) } return {