Blame view

src/components/breadcrumb/breadcrumb-item.vue 1.51 KB
7fa943eb   梁灏   init
1
2
  <template>
      <span>
345c6863   梁灏   update Breadcrumb
3
          <a v-if="href" :class="linkClasses" @click="handleClick">
7fa943eb   梁灏   init
4
5
6
7
8
              <slot></slot>
          </a>
          <span v-else :class="linkClasses">
              <slot></slot>
          </span>
dcbfc232   梁灏   add name of Bread...
9
          <span :class="separatorClasses" v-html="separator" v-if="!showSeparator"></span>
c06e99d0   huixisheng   Support Breadcrumb
10
11
          <span :class="separatorClasses" v-else>
              <slot name="separator"></slot>
7fa943eb   梁灏   init
12
13
14
15
16
17
18
          </span>
      </span>
  </template>
  <script>
      const prefixCls = 'ivu-breadcrumb-item';
  
      export default {
dcbfc232   梁灏   add name of Bread...
19
          name: 'BreadcrumbItem',
7fa943eb   梁灏   init
20
21
22
          props: {
              href: {
                  type: String
345c6863   梁灏   update Breadcrumb
23
24
25
26
              },
              replace: {
                  type: Boolean,
                  default: false
7fa943eb   梁灏   init
27
28
              }
          },
c06e99d0   huixisheng   Support Breadcrumb
29
30
31
32
          data () {
              return {
                  separator: '',
                  showSeparator: false
44412093   huixisheng   [fixed] eslint error
33
              };
c06e99d0   huixisheng   Support Breadcrumb
34
          },
7fa943eb   梁灏   init
35
36
37
38
39
40
41
          computed: {
              linkClasses () {
                  return `${prefixCls}-link`;
              },
              separatorClasses () {
                  return `${prefixCls}-separator`;
              }
345c6863   梁灏   update Breadcrumb
42
43
44
45
46
47
48
49
50
51
52
53
54
          },
          mounted () {
              this.showSeparator = this.$slots.separator !== undefined;
          },
          methods: {
              handleClick () {
                  const isRoute = this.$router;
                  if (isRoute) {
                      this.replace ? this.$router.replace(this.href) : this.$router.push(this.href);
                  } else {
                      window.location.href = this.href;
                  }
              }
7fa943eb   梁灏   init
55
          }
b0893113   jingsam   :art: add eslint
56
57
      };
  </script>