fix[Dashboard]: 页面第一次加载的时候,函数为什么会执行两次? #2601
This commit is contained in:
parent
a85db6ae39
commit
5f6d450bbe
|
@ -33,14 +33,26 @@ export default {
|
||||||
methods: {
|
methods: {
|
||||||
getBreadcrumb() {
|
getBreadcrumb() {
|
||||||
// only show routes with meta.title
|
// 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]
|
const first = matched[0]
|
||||||
|
|
||||||
if (!this.isDashboard(first)) {
|
if (!this.isDashboard(first)) {
|
||||||
matched = [{ path: '/dashboard', meta: { title: 'Dashboard' }}].concat(matched)
|
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) {
|
isDashboard(route) {
|
||||||
const name = route && route.name
|
const name = route && route.name
|
||||||
|
|
Loading…
Reference in New Issue