Skip to content

Commit

Permalink
fix: 使用data变量导致loop render
Browse files Browse the repository at this point in the history
  • Loading branch information
cadecode committed Apr 19, 2023
1 parent fd9783d commit 8deff6f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/layout/component/Sidebar/SidebarItem.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
<template>
<div v-if="!item.hidden">
<template
v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren) && !item.alwaysShow"
v-if="hasOneShowingChild(item.children, item)
&& (!onlyOneChild.children || onlyOneChild.noShowingChildren) && !item.alwaysShow"
>
<app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path)">
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}">
<item :icon="onlyOneChild.meta.icon || (item.meta&&item.meta.icon)" :title="onlyOneChild.meta.title" />
<item :icon="onlyOneChild.meta.icon || (item.meta && item.meta.icon)" :title="onlyOneChild.meta.title" />
</el-menu-item>
</app-link>
</template>
Expand Down Expand Up @@ -53,9 +54,9 @@ export default {
},
data() {
// fix:https://github.com/PanJiaChen/vue-admin-template/issues/237
// this.onlyOneChild = null
this.onlyOneChild = null;
return {
onlyOneChild: null
// onlyOneChild: null
};
},
methods: {
Expand All @@ -72,7 +73,7 @@ export default {
if (showingChildren.length === 1) {
return true;
}
// 没用子路由时显示父级
// 没有子路由时显示父级
if (showingChildren.length === 0) {
this.onlyOneChild = {...parent, path: '', noShowingChildren: true};
return true;
Expand Down

0 comments on commit 8deff6f

Please sign in to comment.