BreadCrumb.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <template>
  2. <div v-show="isShow" class="breadcrumb">
  3. <div class="breadcrumb-container">
  4. <router-link to="/">
  5. <svg-icon icon-class="homepage" />
  6. </router-link>
  7. <i class="el-icon-arrow-right" />
  8. <span v-for="item in routerList" :key="item.path">
  9. <span class="router-title">
  10. <template v-if="item.meta.link">
  11. <router-link :to="item.meta.link"> {{ $t(item.meta.title) }} </router-link>
  12. </template>
  13. <template v-else>
  14. {{ $t(item.meta.title) }}
  15. </template>
  16. </span>
  17. <i class="el-icon-arrow-right" />
  18. </span>
  19. </div>
  20. </div>
  21. </template>
  22. <script>
  23. export default {
  24. name: 'BreadCrumb',
  25. data() {
  26. return {
  27. routerList: []
  28. };
  29. },
  30. computed: {
  31. isShow() {
  32. return this.routerList.length > 0;
  33. }
  34. },
  35. watch: {
  36. $route() {
  37. this.getBreadcrumb();
  38. }
  39. },
  40. created() {
  41. this.getBreadcrumb();
  42. },
  43. methods: {
  44. getBreadcrumb() {
  45. this.routerList = this.$route.matched.filter(item => item.meta && item.meta.title);
  46. this.$emit('update:isShowNav', this.isShow);
  47. }
  48. }
  49. };
  50. </script>
  51. <style lang="scss">
  52. .breadcrumb {
  53. z-index: 999;
  54. width: 100%;
  55. height: 56px;
  56. line-height: 56px;
  57. background-color: #f6ecdd;
  58. &-container {
  59. width: $basic-width;
  60. min-width: $basic-width;
  61. height: 100%;
  62. padding: 15px 0;
  63. margin: 0 auto;
  64. font-weight: 700;
  65. line-height: 26px;
  66. color: #948e85;
  67. vertical-align: middle;
  68. &::before {
  69. display: inline-block;
  70. width: 6px;
  71. height: 100%;
  72. margin-right: 24px;
  73. vertical-align: bottom;
  74. content: '';
  75. background-color: $basic-color;
  76. }
  77. .el-icon-arrow-right {
  78. margin: 0 12px;
  79. }
  80. .router-title {
  81. cursor: pointer;
  82. }
  83. span:last-child {
  84. color: #000;
  85. .el-icon-arrow-right {
  86. display: none;
  87. }
  88. }
  89. }
  90. }
  91. </style>