diff --git a/src/layouts/components/header/Breadcrumb.vue b/src/layouts/components/header/Breadcrumb.vue index b1c091d..edb2c58 100644 --- a/src/layouts/components/header/Breadcrumb.vue +++ b/src/layouts/components/header/Breadcrumb.vue @@ -17,10 +17,7 @@ const router = useRouter(); const routeStore = useRouteStore(); const { routerPush } = useAppRouter(); const routes = computed(() => { - return routeStore.createBreadcrumbFromRoutes( - (router.currentRoute.value.name as string) || '/', - routeStore.userRoutes, - ); + return routeStore.createBreadcrumbFromRoutes(router.currentRoute.value.name as string!, routeStore.userRoutes); }); diff --git a/src/store/modules/route.ts b/src/store/modules/route.ts index 9cc0a9c..fd7d0a3 100644 --- a/src/store/modules/route.ts +++ b/src/store/modules/route.ts @@ -33,7 +33,7 @@ export const useRouteStore = defineStore('route-store', { router.removeRoute('appRoot'); }, /* 根据当前路由的name生成面包屑数据 */ - createBreadcrumbFromRoutes(routeName: string, userRoutes: AppRoute.Route[]) { + createBreadcrumbFromRoutes(routeName = '/', userRoutes: AppRoute.Route[]) { const path: AppRoute.Route[] = []; // 筛选所有包含目标的各级路由组合成一维数组 const getPathfromRoutes = (routeName: string, userRoutes: AppRoute.Route[]) => {