Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
VueElementTemplate
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄瑜
VueElementTemplate
Commits
a932272b
Commit
a932272b
authored
Oct 26, 2017
by
Pan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor:router
parent
577e4dc1
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
122 additions
and
85 deletions
+122
-85
index.js
src/router/index.js
+108
-73
Levelbar.vue
src/views/layout/components/Levelbar.vue
+4
-4
SidebarItem.vue
src/views/layout/components/SidebarItem.vue
+10
-8
No files found.
src/router/index.js
View file @
a932272b
This diff is collapsed.
Click to expand it.
src/views/layout/components/Levelbar.vue
View file @
a932272b
<
template
>
<el-breadcrumb
class=
"app-levelbar"
separator=
"/"
>
<el-breadcrumb-item
v-for=
"(item,index) in levelList"
:key=
"item.path"
>
<span
v-if=
'item.redirect==="noredirect"||index==levelList.length-1'
class=
"no-redirect"
>
{{
item
.
nam
e
}}
</span>
<router-link
v-else
:to=
"item.redirect||item.path"
>
{{
item
.
nam
e
}}
</router-link>
<el-breadcrumb-item
v-for=
"(item,index) in levelList"
:key=
"item.path"
v-if=
'item.meta.title'
>
<span
v-if=
'item.redirect==="noredirect"||index==levelList.length-1'
class=
"no-redirect"
>
{{
item
.
meta
.
titl
e
}}
</span>
<router-link
v-else
:to=
"item.redirect||item.path"
>
{{
item
.
meta
.
titl
e
}}
</router-link>
</el-breadcrumb-item>
</el-breadcrumb>
</
template
>
...
...
@@ -22,7 +22,7 @@ export default {
let
matched
=
this
.
$route
.
matched
.
filter
(
item
=>
item
.
name
)
const
first
=
matched
[
0
]
if
(
first
&&
(
first
.
name
!==
'首页'
||
first
.
path
!==
''
))
{
matched
=
[{
name
:
'首页'
,
path
:
'/'
}].
concat
(
matched
)
matched
=
[{
path
:
'/'
,
meta
:
{
title
:
'首页'
}
}].
concat
(
matched
)
}
this
.
levelList
=
matched
}
...
...
src/views/layout/components/SidebarItem.vue
View file @
a932272b
...
...
@@ -2,28 +2,30 @@
<div
class=
'menu-wrapper'
>
<template
v-for=
"item in routes"
>
<router-link
v-if=
"!item.hidden&&item.
noDropdown&&item.children.length>0"
:to=
"item.path+'/'+item.children[0].path"
>
<router-link
v-if=
"!item.hidden&&item.
children&&item.children.length===1"
: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'
>
<svg-icon
v-if=
'item.icon'
:icon-class=
"item.icon"
></svg-icon><span>
{{
item
.
children
[
0
].
name
}}
</span>
<svg-icon
v-if=
'item.children[0].meta&&item.children[0].meta.icon'
:icon-class=
"item.children[0].meta.icon"
></svg-icon>
<span>
{{
item
.
children
[
0
].
meta
?
item
.
children
[
0
].
meta
.
title
:
'no title'
}}
</span>
</el-menu-item>
</router-link>
<el-submenu
:index=
"item.name"
v-if=
"
!item.noDropdown&&!item.hidden"
>
<el-submenu
:index=
"item.name"
v-if=
"
item.children&&item.children.length>1&&!item.hidden"
:key=
'item.name'
>
<template
slot=
"title"
>
<svg-icon
v-if=
'item.icon'
:icon-class=
"item.icon"
></svg-icon><span>
{{
item
.
name
}}
</span>
<svg-icon
v-if=
'item.meta&&item.meta.icon'
:icon-class=
"item.meta.icon"
></svg-icon>
<span>
{{
item
.
meta
?
item
.
meta
.
title
:
'no title'
}}
</span>
</
template
>
<
template
v-for=
"child in item.children"
v-if=
'!child.hidden'
>
<sidebar-item
class=
'nest-menu'
v-if=
'child.children&&child.children.length>0'
:routes=
'[child]'
>
</sidebar-item>
<sidebar-item
class=
'nest-menu'
v-if=
'child.children&&child.children.length>0'
:routes=
'[child]'
:key=
'child.path'
>
</sidebar-item>
<router-link
v-else
:to=
"item.path+'/'+child.path"
>
<router-link
v-else
:to=
"item.path+'/'+child.path"
:key=
'child.name'
>
<el-menu-item
:index=
"item.path+'/'+child.path"
>
<svg-icon
v-if=
'child.icon'
:icon-class=
"child.icon"
></svg-icon><span>
{{
child
.
name
}}
</span>
<svg-icon
v-if=
'child.meta&&child.meta.icon'
:icon-class=
"child.meta.icon"
></svg-icon>
<span
v-if=
'child.meta'
>
{{
child
.
meta
.
title
}}
</span>
</el-menu-item>
</router-link>
</
template
>
</el-submenu>
</template>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment