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