浏览代码

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