Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3678bd1

Browse files
committed
perf[Breadcrumb]: refine getBreadcrumb function
1 parent 4ee334a commit 3678bd1

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/components/Breadcrumb/index.vue

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,23 @@ export default {
3131
methods: {
3232
generateTitle,
3333
getBreadcrumb() {
34-
// only show routes with name
35-
let matched = this.$route.matched.filter(item => item.name)
36-
34+
// only show routes with meta.title
35+
let matched = this.$route.matched.filter(item => item.meta && item.meta.title)
3736
const first = matched[0]
38-
if (first && first.name.trim().toLocaleLowerCase() !== 'Dashboard'.toLocaleLowerCase()) {
37+
38+
if (!this.isDashboard(first)) {
3939
matched = [{ path: '/dashboard', meta: { title: 'dashboard' }}].concat(matched)
4040
}
4141
4242
this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false)
4343
},
44+
isDashboard(route) {
45+
const name = route && route.name
46+
if (!name) {
47+
return false
48+
}
49+
return name.trim().toLocaleLowerCase() === 'Dashboard'.toLocaleLowerCase()
50+
},
4451
pathCompile(path) {
4552
// To solve this problem https://github.com/PanJiaChen/vue-element-admin/issues/561
4653
const { params } = this.$route

0 commit comments

Comments
 (0)