fix[Dashboard]: 页面第一次加载的时候,函数为什么会执行两次? #2601

This commit is contained in:
马云海 2019-09-29 20:03:39 +08:00
parent a85db6ae39
commit 5f6d450bbe
1 changed files with 14 additions and 2 deletions

View File

@ -33,14 +33,26 @@ export default {
methods: {
getBreadcrumb() {
// only show routes with meta.title
let matched = this.$route.matched.filter(item => item.meta && item.meta.title)
let matched = []
this.$route.matched.forEach(item => {
if (item.meta && item.meta.title && item.meta.breadcrumb !== false) {
matched.push({
meta: {
title: item.meta.title
},
path: item.path,
name: item.name
})
}
})
const first = matched[0]
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)
this.levelList = matched
},
isDashboard(route) {
const name = route && route.name