index.vue 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <div v-if="isShowBreadcrumb" class="breadcrumb">
  3. <SvgIcon :icon-class="breadcrumb[0].meta.icon" />
  4. <ul>
  5. <li v-for="({ meta: { title }, path, redirect }, i) in breadcrumb" :key="title">
  6. <span class="separator">/</span>
  7. <span :key="i" class="breadcrumb-name" @click="$router.push(path.length > 0 ? path : redirect)">
  8. {{ title }}
  9. </span>
  10. </li>
  11. </ul>
  12. </div>
  13. </template>
  14. <script>
  15. export default {
  16. name: 'LayoutBreadcrumb',
  17. data() {
  18. return {
  19. breadcrumb: [],
  20. };
  21. },
  22. computed: {
  23. isShowBreadcrumb() {
  24. return this.breadcrumb.length > 0;
  25. },
  26. },
  27. watch: {
  28. $route() {
  29. this.getBreadcrumb();
  30. },
  31. },
  32. created() {
  33. this.getBreadcrumb();
  34. },
  35. methods: {
  36. getBreadcrumb() {
  37. // this.breadcrumb = this.$route.matched.filter((item) => item?.meta && item.meta.title);
  38. // this.$emit('update:isShowBreadcrumb', this.isShowBreadcrumb);
  39. },
  40. },
  41. };
  42. </script>
  43. <style lang="scss" scoped>
  44. .breadcrumb {
  45. display: flex;
  46. align-items: center;
  47. height: 40px;
  48. padding: 5px;
  49. > ul {
  50. display: flex;
  51. li {
  52. font-weight: 400;
  53. color: $font-light-color;
  54. .separator {
  55. margin: 0 8px;
  56. color: #c9cdd4;
  57. }
  58. .breadcrumb-name {
  59. font-size: 14px;
  60. }
  61. &:not(:last-child) {
  62. cursor: pointer;
  63. }
  64. &:nth-last-child(1) {
  65. font-weight: bold;
  66. color: $font-color;
  67. }
  68. }
  69. }
  70. }
  71. </style>