fix: when the server component path is wrong, a blank interface is still displayed (#4567)

This commit is contained in:
Vben
2024-10-05 11:11:30 +08:00
committed by GitHub
parent 0fcc42a2fb
commit 402eaf4275
2 changed files with 16 additions and 6 deletions

View File

@@ -53,13 +53,20 @@ function transformComponent(
component: VNode,
route: RouteLocationNormalizedLoadedGeneric,
) {
// 组件视图未找到,如果有设置后备视图,则返回后备视图,如果没有,则抛出错误
if (!component) {
console.error(
'Component view not foundplease check the route configuration',
);
return undefined;
}
const routeName = route.name as string;
// 如果组件没有 name则直接返回
if (!routeName) {
return component;
}
const componentName = (component.type as any).name;
const componentName = (component?.type as any)?.name;
// 已经设置过 name则直接返回
if (componentName) {