Procházet zdrojové kódy

fix:SidebarItem组件报错

zh před 2 roky
rodič
revize
9fd72b99d9
1 změnil soubory, kde provedl 4 přidání a 4 odebrání
  1. 4 4
      src/layout/components/Sidebar/SidebarItem.vue

+ 4 - 4
src/layout/components/Sidebar/SidebarItem.vue

@@ -7,7 +7,7 @@
         (!onlyOneChild.children ||
           onlyOneChild.noShowingChildren ||
           (onlyOneChild.children &&
-            onlyOneChild.children.length < 1 &&
+          onlyOneChild.children&& onlyOneChild.children.length < 1 &&
             (onlyOneChild.name == 'issue_index' ||
               onlyOneChild.name == 'notice_index' ||
               onlyOneChild.name == 'dashboard'))) &&
@@ -78,7 +78,7 @@ export default {
           // Temp set(will be used if only has one showing child)
 
           // 删除空的children
-          if (item.children.length < 1) {
+          if (item.children&&item.children.length < 1) {
             // delete item['children']
           }
 
@@ -90,12 +90,12 @@ export default {
       })
 
       // When there is only one child router, the child router is displayed by default
-      if (showingChildren.length === 1) {
+      if (showingChildren&&showingChildren.length === 1) {
         return true
       }
 
       // Show parent if there are no child router to display
-      if (showingChildren.length === 0) {
+      if (showingChildren&&showingChildren.length === 0) {
         this.onlyOneChild = { ...parent, path: '', noShowingChildren: true }
         return true
       }