Skip to content

Commit 7041c6a

Browse files
authored
chore: output console error for invalid route component (#5593)
1 parent 12ffb31 commit 7041c6a

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

packages/utils/src/helpers/generate-routes-backend.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,14 @@ function convertRoutes(
5656
// 页面组件转换
5757
} else if (component) {
5858
const normalizePath = normalizeViewPath(component);
59-
route.component =
60-
pageMap[
61-
normalizePath.endsWith('.vue')
62-
? normalizePath
63-
: `${normalizePath}.vue`
64-
];
59+
const pageKey = normalizePath.endsWith('.vue')
60+
? normalizePath
61+
: `${normalizePath}.vue`;
62+
if (pageMap[pageKey]) {
63+
route.component = pageMap[pageKey];
64+
} else {
65+
console.error(`route component is invalid: ${pageKey}`, route);
66+
}
6567
}
6668

6769
return route;

0 commit comments

Comments
 (0)