diff --git a/src/components/Breadcrumb/index.vue b/src/components/Breadcrumb/index.vue index 1ea13031..b89d8da6 100644 --- a/src/components/Breadcrumb/index.vue +++ b/src/components/Breadcrumb/index.vue @@ -31,16 +31,23 @@ export default { methods: { generateTitle, getBreadcrumb() { - // only show routes with name - let matched = this.$route.matched.filter(item => item.name) - + // only show routes with meta.title + let matched = this.$route.matched.filter(item => item.meta && item.meta.title) const first = matched[0] - if (first && first.name.trim().toLocaleLowerCase() !== 'Dashboard'.toLocaleLowerCase()) { + + if (!this.isDashboard(first)) { matched = [{ path: '/dashboard', meta: { title: 'dashboard' }}].concat(matched) } this.levelList = matched.filter(item => item.meta && item.meta.title && item.meta.breadcrumb !== false) }, + isDashboard(route) { + const name = route && route.name + if (!name) { + return false + } + return name.trim().toLocaleLowerCase() === 'Dashboard'.toLocaleLowerCase() + }, pathCompile(path) { // To solve this problem https://github.com/PanJiaChen/vue-element-admin/issues/561 const { params } = this.$route