33b8eae28646727d5b198c1691e6cad5e3d5d91f.svn-base 1.1 KB

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