vue-router#RouteRecord TypeScript Examples
The following examples show how to use
vue-router#RouteRecord.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.ts From vite-vue3-ts with MIT License | 6 votes |
// 过滤路由属性 hideInMenu hideChildInMenu
export function clearMenuItem(menusData: RouteRecord[] | RouteRecordRaw[]): RouteRecordRaw[] {
const filterHideMenus = menusData
.map((item: RouteRecord | RouteRecordRaw) => {
const finalItem = { ...item };
if (!finalItem.name || finalItem.meta?.hideInMenu) {
return null;
}
if (finalItem && finalItem?.children) {
if (
!finalItem.meta?.hideChildInMenu &&
finalItem.children.some(
(child: RouteRecord | RouteRecordRaw) => child && child.name && !child.meta?.hideInMenu,
)
) {
return {
...item,
children: clearMenuItem(finalItem.children),
};
}
delete finalItem.children;
}
return finalItem;
})
.filter((item) => item) as IRouteRecordRaw[];
//
return filterHideMenus;
}