Browse Source

解决左侧菜单只有一个时显示错误

gcz 4 years ago
parent
commit
04a802ce97

+ 1 - 1
src/router/index.js

@@ -29,7 +29,7 @@ export const constantRouterMap = [
       path: 'home',
       name: 'home',
       component: () => import('@/views/home/index'),
-      meta: {title: '首页', icon: 'home'}
+      meta: {title: '首页', icon: 'home'},
     }]
   }
 ]

+ 1 - 1
src/views/layout/components/Sidebar/SidebarItem.vue

@@ -2,7 +2,7 @@
   <div class="menu-wrapper">
     <template v-for="item in routes" v-if="!item.hidden&&item.children">
 
-      <router-link v-if="hasOneShowingChildren(item.children) && !item.children[0].children&&!item.alwaysShow" :to="item.path+'/'+item.children[0].path"
+      <router-link v-if="hasOneShowingChildren(item.children) && !item.children[0].children&&!item.alwaysShow&&item.children[0].path=='home'" :to="item.path+'/'+item.children[0].path"
         :key="item.children[0].name">
         <el-menu-item :index="item.path+'/'+item.children[0].path" :class="{'submenu-title-noDropdown':!isNest}">
           <svg-icon v-if="item.children[0].meta&&item.children[0].meta.icon" :icon-class="item.children[0].meta.icon"></svg-icon>

+ 1 - 1
src/views/layout/components/Sidebar/index.vue

@@ -27,7 +27,7 @@ export default {
       'routers'
     ]),
     routes() {
-      // console.log('this.routers',JSON.parse(JSON.stringify(this.routers)))
+      console.log('this.routers',JSON.parse(JSON.stringify(this.routers)))
       // return this.$router.options.routes
       return this.routers
     },