界面
This commit is contained in:
@@ -14,6 +14,20 @@ export function getParentChildrenRoutes(route: RouteLocationNormalized): RouteRe
|
||||
return [];
|
||||
}
|
||||
|
||||
// 返回有 title 的子路由
|
||||
return parentRoute.children.filter((child: RouteRecordRaw) => child.meta?.title);
|
||||
// 返回有 title 的子路由,但排除父路由本身(path 为空字符串或 name 以 _page 结尾的子路由)
|
||||
return parentRoute.children.filter((child: RouteRecordRaw) => {
|
||||
// 必须有 title
|
||||
if (!child.meta?.title) {
|
||||
return false;
|
||||
}
|
||||
// 排除 path 为空字符串的子路由(代表父路由本身)
|
||||
if (child.path === '' || child.path === undefined) {
|
||||
return false;
|
||||
}
|
||||
// 排除 name 以 _page 结尾的子路由(父路由的默认子路由)
|
||||
if (typeof child.name === 'string' && child.name.endsWith('_page')) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user