From 30c682bd24fb94c90762765af21b192b5c6cb484 Mon Sep 17 00:00:00 2001 From: xiaoxian521 <1923740402@qq.com> Date: Tue, 23 Aug 2022 10:24:40 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D`iframe`=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/utils.ts | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/router/utils.ts b/src/router/utils.ts index 988f9ed36..62d6bb07a 100644 --- a/src/router/utils.ts +++ b/src/router/utils.ts @@ -235,12 +235,15 @@ function addAsyncRoutes(arrRoutes: Array) { // 父级的name属性取值:如果子级存在且父级的name属性不存在,默认取第一个子级的name;如果子级存在且父级的name属性存在,取存在的name属性,会覆盖默认值 if (v?.children && v.children.length && !v.name) v.name = v.children[0].name; - if (v.meta?.frameSrc) v.component = IFrame; - // 对后端传component组件路径和不传做兼容(如果后端传component组件路径,那么path可以随便写,如果不传,component组件路径会跟path保持一致) - const index = v?.component - ? modulesRoutesKeys.findIndex(ev => ev.includes(v.component as any)) - : modulesRoutesKeys.findIndex(ev => ev.includes(v.path)); - v.component = modulesRoutes[modulesRoutesKeys[index]]; + if (v.meta?.frameSrc) { + v.component = IFrame; + } else { + // 对后端传component组件路径和不传做兼容(如果后端传component组件路径,那么path可以随便写,如果不传,component组件路径会跟path保持一致) + const index = v?.component + ? modulesRoutesKeys.findIndex(ev => ev.includes(v.component as any)) + : modulesRoutesKeys.findIndex(ev => ev.includes(v.path)); + v.component = modulesRoutes[modulesRoutesKeys[index]]; + } if (v?.children && v.children.length) { addAsyncRoutes(v.children); }