index.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <el-breadcrumb class="breadcrumb-container" separator=">">
  3. <el-breadcrumb-item v-for="item in list" :key="item.path">
  4. {{ item.meta.title }}
  5. </el-breadcrumb-item>
  6. </el-breadcrumb>
  7. </template>
  8. <script>
  9. export default {
  10. name: 'VabBreadcrumb',
  11. data() {
  12. return {
  13. list: this.getBreadcrumb(),
  14. }
  15. },
  16. watch: {
  17. $route() {
  18. this.list = this.getBreadcrumb()
  19. },
  20. },
  21. methods: {
  22. getBreadcrumb() {
  23. return this.$route.matched.filter(
  24. (item) => item.name && item.meta.title
  25. )
  26. },
  27. },
  28. }
  29. </script>
  30. <style lang="scss" scoped>
  31. .breadcrumb-container {
  32. height: $base-nav-bar-height;
  33. font-size: $base-font-size-default;
  34. line-height: $base-nav-bar-height;
  35. ::v-deep {
  36. .el-breadcrumb__item {
  37. .el-breadcrumb__inner {
  38. a {
  39. display: flex;
  40. float: left;
  41. font-weight: normal;
  42. color: #515a6e;
  43. i {
  44. margin-right: 3px;
  45. }
  46. }
  47. }
  48. &:last-child {
  49. .el-breadcrumb__inner {
  50. a {
  51. color: #999;
  52. }
  53. }
  54. }
  55. }
  56. }
  57. }
  58. </style>