ソースを参照

首页未选中bug

shilipojs 2 年 前
コミット
d06e8d328e
1 ファイル変更12 行追加9 行削除
  1. 12 9
      src/components/Top/index.vue

+ 12 - 9
src/components/Top/index.vue

@@ -137,7 +137,7 @@ export default {
       auth.setMenuTab(data)
       auth.setActiveMenu(data.path + '/' + data.children[0].path)
       let item = JSON.parse(JSON.stringify(data))
-      let routes = [] //三级菜单
+      let routes = undefined //三级菜单
       let second = [] //二级
       let routesTo = []
       if (item.children) {
@@ -147,25 +147,28 @@ export default {
             item2.children.forEach((item3) => {
               item3.path = item.path + '/' + item2.path + '/' + item3.path
             })
-            if (routes.length == 0 && item2.children.length) {
+            if (!routes && item2.children.length) {
               //一级菜单下面第一个有3个菜单的二级菜单
               routes = item2.children
               routesTo = item2.children
             }
           } else {
+            routes = []
             routesTo = item.children
           }
           item2.path = item.path + '/' + item2.path
           item2.level = 2
           second.push(item2)
         })
-        let fal = false
-        second.forEach((item) => {
-          if (!fal && item.children && item.children.length > 0) {
-            auth.setActiveMenu(item.path)
-            fal = true
-          }
-        })
+        // let fal = false
+        //选中第一个
+        auth.setActiveMenu(second[0].path)
+        // second.forEach((item) => {
+        //   if (!fal && item.children && item.children.length > 0) {
+        //     auth.setActiveMenu(item.path)
+        //     fal = true
+        //   }
+        // })
         auth.setMenuTab(second)
         this.three = true
         this.$store.commit('SET_SIDEBAR_ROUTERS', routes)