Skip to content

Commit

Permalink
fix:[menu]: some bug in only has one showing child #484
Browse files Browse the repository at this point in the history
  • Loading branch information
PanJiaChen committed Mar 22, 2018
1 parent 88c28f5 commit de06619
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/views/layout/components/Sidebar/SidebarItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div class="menu-wrapper">
<template v-for="item in routes" v-if="!item.hidden&&item.children">

<router-link v-if="item.children.length===1 && !item.children[0].children&&!item.alwaysShow" :to="item.path+'/'+item.children[0].path" :key="item.children[0].name">
<router-link v-if="hasOneShowingChildren(item.children) && !item.children[0].children&&!item.alwaysShow" :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>
<span v-if="item.children[0].meta&&item.children[0].meta.title">{{generateTitle(item.children[0].meta.title)}}</span>
Expand Down Expand Up @@ -46,6 +46,15 @@ export default {
}
},
methods: {
hasOneShowingChildren(children) {
const showingChildren = children.filter(item => {
return !item.hidden
})
if (showingChildren.length === 1) {
return true
}
return false
},
generateTitle
}
}
Expand Down

0 comments on commit de06619

Please sign in to comment.