diff --git a/src/utils/routerHelper.ts b/src/utils/routerHelper.ts index 7a87bd75..cf1b3622 100644 --- a/src/utils/routerHelper.ts +++ b/src/utils/routerHelper.ts @@ -101,7 +101,7 @@ export const generateRoute = (routes: AppCustomRouteRecordRaw[]): AppRouteRecord if (!route.children && route.parentId == 0 && route.component) { data.component = Layout data.meta = { - hidden: meta.hidden, + hidden: meta.hidden } data.name = toCamelCase(route.path, true) + 'Parent' data.redirect = '' @@ -170,8 +170,9 @@ const generateRoutePath = (parentPath: string, path: string) => { } export const pathResolve = (parentPath: string, path: string) => { if (isUrl(path)) return path - const childPath = path.startsWith('/') || !path ? path : `/${path}` - return `${parentPath}${childPath}`.replace(/\/\//g, '/') + if (!path) return parentPath // 修复 path 为空时返回 parentPath,避免拼接出错 https://t.zsxq.com/QVr6b + const childPath = path.startsWith('/') ? path : `/${path}` + return `${parentPath}${childPath}`.replace(/\/+/g, '/') } // 路由降级