commit | author | age
|
9bcb19
|
1 |
<template> |
I |
2 |
<a-breadcrumb class="breadcrumb"> |
|
3 |
<a-breadcrumb-item v-for="(item, index) in breadList" :key="item.name"> |
|
4 |
<router-link |
|
5 |
v-if="item.name != name && index != 1" |
|
6 |
:to="{ path: item.path === '' ? '/' : item.path }" |
|
7 |
>{{ item.meta.title }}</router-link> |
|
8 |
<span v-else>{{ item.meta.title }}</span> |
|
9 |
</a-breadcrumb-item> |
|
10 |
</a-breadcrumb> |
|
11 |
</template> |
|
12 |
|
|
13 |
<script> |
|
14 |
export default { |
|
15 |
data () { |
|
16 |
return { |
|
17 |
name: '', |
|
18 |
breadList: [] |
|
19 |
} |
|
20 |
}, |
|
21 |
created () { |
|
22 |
this.getBreadcrumb() |
|
23 |
}, |
|
24 |
methods: { |
|
25 |
getBreadcrumb () { |
|
26 |
this.breadList = [] |
|
27 |
// this.breadList.push({name: 'index', path: '/dashboard/', meta: {title: '首页'}}) |
|
28 |
|
|
29 |
this.name = this.$route.name |
|
30 |
this.$route.matched.forEach(item => { |
|
31 |
// item.name !== 'index' && this.breadList.push(item) |
|
32 |
this.breadList.push(item) |
|
33 |
}) |
|
34 |
} |
|
35 |
}, |
|
36 |
watch: { |
|
37 |
$route () { |
|
38 |
this.getBreadcrumb() |
|
39 |
} |
|
40 |
} |
|
41 |
} |
|
42 |
</script> |
|
43 |
|
|
44 |
<style scoped> |
|
45 |
</style> |