Breadcrumb.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <div ref="breadcrumbRef" class="breadcrumb">
  3. <slot />
  4. </div>
  5. </template>
  6. <script lang="ts">
  7. import type { PropType } from 'vue';
  8. import { defineComponent, provide, ref } from 'vue';
  9. export default defineComponent({
  10. name: 'Breadcrumb',
  11. props: {
  12. separator: {
  13. type: String as PropType<string>,
  14. default: '/',
  15. },
  16. separatorClass: {
  17. type: String as PropType<string>,
  18. default: '',
  19. },
  20. },
  21. setup(props) {
  22. const breadcrumbRef = ref<Nullable<HTMLElement>>(null);
  23. provide('breadcrumb', props);
  24. return {
  25. breadcrumbRef,
  26. };
  27. },
  28. });
  29. </script>
  30. <style lang="less">
  31. @import (reference) '../../design/index.less';
  32. .breadcrumb {
  33. .unselect();
  34. height: @header-height;
  35. padding-right: 20px;
  36. font-size: 13px;
  37. line-height: @header-height;
  38. // line-height: 1;
  39. &::after,
  40. &::before {
  41. display: table;
  42. content: '';
  43. }
  44. &::after {
  45. clear: both;
  46. }
  47. &__separator {
  48. margin: 0 9px;
  49. font-weight: 700;
  50. color: @breadcrumb-item-normal-color;
  51. &[class*='icon'] {
  52. margin: 0 6px;
  53. font-weight: 400;
  54. }
  55. }
  56. &__item {
  57. float: left;
  58. }
  59. &__inner {
  60. color: @breadcrumb-item-normal-color;
  61. &.is-link,
  62. a {
  63. font-weight: 500;
  64. color: @text-color-base;
  65. text-decoration: none;
  66. transition: color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  67. }
  68. a:hover,
  69. &.is-link:hover {
  70. color: @primary-color;
  71. cursor: pointer;
  72. }
  73. }
  74. &__item:last-child .breadcrumb__inner,
  75. &__item:last-child &__inner a,
  76. &__item:last-child &__inner a:hover,
  77. &__item:last-child &__inner:hover {
  78. font-weight: 400;
  79. color: @breadcrumb-item-normal-color;
  80. cursor: text;
  81. }
  82. &__item:last-child &__separator {
  83. display: none;
  84. }
  85. }
  86. </style>