Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ef42cea

Browse filesBrowse files
committed
refactor(Breadcrumb): filter routeRecords array, getName cleanup
- add computed `routeRecords` - filter for `name` or `meta.label` - rename `showName` to `getName` & cleanup
1 parent 4304cdb commit ef42cea
Copy full SHA for ef42cea

File tree

Expand file treeCollapse file tree

1 file changed

+11
-12
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+11
-12
lines changed

‎src/components/Breadcrumb/Breadcrumb.vue

Copy file name to clipboardExpand all lines: src/components/Breadcrumb/Breadcrumb.vue
+11-12Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<template>
22
<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>
66
</li>
77
</ol>
88
</template>
@@ -17,17 +17,16 @@ export default {
1717
}
1818
},
1919
methods: {
20+
getName (item) {
21+
return item.meta && item.meta.label ? item.meta.label : item.name || null
22+
},
2023
isLast (index) {
2124
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)
3130
}
3231
}
3332
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.