mirror of
https://github.com/pure-admin/pure-admin-thin.git
synced 2025-04-24 23:47:17 +08:00
Fix: Ensure route.children existence before accessing in initRouter()
In the initRouter() function, added a check to ensure the existence of route.children before accessing it. This prevents the "TypeError: Cannot read properties of undefined" error that occurred when trying to access route.children[0] without confirming its existence. The check ensures that route.children is present and not an empty array before proceeding to access its elements.
This commit is contained in:
parent
c1db073b23
commit
e63e2152d6
@ -158,7 +158,12 @@ router.beforeEach((to: ToRouteType, _from, next) => {
|
||||
getTopMenu(true);
|
||||
// query、params模式路由传参数的标签页不在此处处理
|
||||
if (route && route.meta?.title) {
|
||||
if (isAllEmpty(route.parentId) && route.meta?.backstage) {
|
||||
if (
|
||||
isAllEmpty(route.parentId) &&
|
||||
route.meta?.backstage &&
|
||||
route.children &&
|
||||
route.children.length > 0
|
||||
) {
|
||||
// 此处为动态顶级路由(目录)
|
||||
const { path, name, meta } = route.children[0];
|
||||
useMultiTagsStoreHook().handleTags("push", {
|
||||
|
Loading…
x
Reference in New Issue
Block a user