File tree 1 file changed +11
-12
lines changed
src/components/Breadcrumb 1 file changed +11
-12
lines changed Original file line number Diff line number Diff line change 1
1
<template >
2
2
<ol class =" breadcrumb" >
3
- <li class =" breadcrumb-item" :key =" index" v-for =" (item , index) in list " >
4
- <span class =" active" v-if =" isLast(index)" >{{ showName(item ) }}</span >
5
- <router-link :to =" item " v-else >{{ showName(item ) }}</router-link >
3
+ <li class =" breadcrumb-item" :key =" index" v-for =" (routeObject , index) in routeRecords " >
4
+ <span class =" active" v-if =" isLast(index)" >{{ getName(routeObject ) }}</span >
5
+ <router-link :to =" routeObject " v-else >{{ getName(routeObject ) }}</router-link >
6
6
</li >
7
7
</ol >
8
8
</template >
@@ -17,17 +17,16 @@ export default {
17
17
}
18
18
},
19
19
methods: {
20
+ getName (item ) {
21
+ return item .meta && item .meta .label ? item .meta .label : item .name || null
22
+ },
20
23
isLast (index ) {
21
24
return index === this .list .length - 1
22
- },
23
- showName (item ) {
24
- if (item .meta && item .meta .label ) {
25
- item = item .meta && item .meta .label
26
- }
27
- if (item .name ) {
28
- item = item .name
29
- }
30
- return item
25
+ }
26
+ },
27
+ computed: {
28
+ routeRecords : function () {
29
+ return this .list .filter ((route ) => route .name || route .meta .label )
31
30
}
32
31
}
33
32
}
You can’t perform that action at this time.
0 commit comments