Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
Support
提交反馈
为 GitLab 提交贡献
登录
切换导航
兵
兵役_吉林工业
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
麦嘉得
兵役_吉林工业
提交
adec74c0
提交
adec74c0
编写于
9月 17, 2018
作者:
Pan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed: sidebar has no children bug
上级
8df73228
变更
1
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
14 行增加
和
6 行删除
+14
-6
SidebarItem.vue
src/views/layout/components/Sidebar/SidebarItem.vue
+14
-6
未找到文件。
src/views/layout/components/Sidebar/SidebarItem.vue
浏览文件 @
adec74c0
<
template
>
<
template
>
<div
v-if=
"!item.hidden&&item.children"
class=
"menu-wrapper"
>
<div
v-if=
"!item.hidden&&item.children"
class=
"menu-wrapper"
>
<template
v-if=
"hasOneShowingChild(item.children
) && !onlyOneChild.children
&&!item.alwaysShow"
>
<template
v-if=
"hasOneShowingChild(item.children
,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)
&&!item.alwaysShow"
>
<a
:href=
"onlyOneChild.path"
target=
"_blank"
@
click=
"clickLink(onlyOneChild.path,$event)"
>
<a
:href=
"onlyOneChild.path"
target=
"_blank"
@
click=
"clickLink(onlyOneChild.path,$event)"
>
<el-menu-item
:index=
"resolvePath(onlyOneChild.path)"
:class=
"
{'submenu-title-noDropdown':!isNest}">
<el-menu-item
:index=
"resolvePath(onlyOneChild.path)"
:class=
"
{'submenu-title-noDropdown':!isNest}">
<item
v-if=
"onlyOneChild.meta"
:icon=
"onlyOneChild.meta.icon||item.meta.icon"
:title=
"onlyOneChild.meta.title"
/>
<item
v-if=
"onlyOneChild.meta"
:icon=
"onlyOneChild.meta.icon||item.meta.icon"
:title=
"onlyOneChild.meta.title"
/>
...
@@ -21,8 +21,7 @@
...
@@ -21,8 +21,7 @@
:item=
"child"
:item=
"child"
:key=
"child.path"
:key=
"child.path"
:base-path=
"resolvePath(child.path)"
:base-path=
"resolvePath(child.path)"
class=
"nest-menu"
/>
class=
"nest-menu"
/>
<a
v-else
:href=
"child.path"
:key=
"child.name"
target=
"_blank"
@
click=
"clickLink(child.path,$event)"
>
<a
v-else
:href=
"child.path"
:key=
"child.name"
target=
"_blank"
@
click=
"clickLink(child.path,$event)"
>
<el-menu-item
:index=
"resolvePath(child.path)"
>
<el-menu-item
:index=
"resolvePath(child.path)"
>
<item
v-if=
"child.meta"
:icon=
"child.meta.icon"
:title=
"child.meta.title"
/>
<item
v-if=
"child.meta"
:icon=
"child.meta.icon"
:title=
"child.meta.title"
/>
...
@@ -43,7 +42,7 @@ export default {
...
@@ -43,7 +42,7 @@ export default {
name
:
'
SidebarItem
'
,
name
:
'
SidebarItem
'
,
components
:
{
Item
},
components
:
{
Item
},
props
:
{
props
:
{
// route
配置json
// route
object
item
:
{
item
:
{
type
:
Object
,
type
:
Object
,
required
:
true
required
:
true
...
@@ -63,19 +62,28 @@ export default {
...
@@ -63,19 +62,28 @@ export default {
}
}
},
},
methods
:
{
methods
:
{
hasOneShowingChild
(
children
)
{
hasOneShowingChild
(
children
,
parent
)
{
const
showingChildren
=
children
.
filter
(
item
=>
{
const
showingChildren
=
children
.
filter
(
item
=>
{
if
(
item
.
hidden
)
{
if
(
item
.
hidden
)
{
return
false
return
false
}
else
{
}
else
{
//
temp set(will be used if only has one showing child
)
//
Temp set(will be used if only has one showing child
)
this
.
onlyOneChild
=
item
this
.
onlyOneChild
=
item
return
true
return
true
}
}
})
})
// When there is only one child router, the child router is displayed by default
if
(
showingChildren
.
length
===
1
)
{
if
(
showingChildren
.
length
===
1
)
{
return
true
return
true
}
}
// Show parent if there are no child router to display
if
(
showingChildren
.
length
===
0
)
{
this
.
onlyOneChild
=
{
...
parent
,
path
:
''
,
noShowingChildren
:
true
}
return
true
}
return
false
return
false
},
},
resolvePath
(
routePath
)
{
resolvePath
(
routePath
)
{
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录