Ver código fonte

fix:SidebarItem组件报错

zh 2 anos atrás
pai
commit
9fd72b99d9
1 arquivos alterados com 4 adições e 4 exclusões
  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
       }