Blame view

node_modules/element-ui/packages/breadcrumb/src/breadcrumb-item.vue 1.03 KB
2a09d1a4   liuqimichale   添加宜春 天水 宣化
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
  <template>
    <span class="el-breadcrumb__item">
      <span
        :class="['el-breadcrumb__inner', to ? 'is-link' : '']"
        ref="link"
        role="link">
        <slot></slot>
      </span>
      <i v-if="separatorClass" class="el-breadcrumb__separator" :class="separatorClass"></i>
      <span v-else class="el-breadcrumb__separator" role="presentation">{{separator}}</span>
    </span>
  </template>
  <script>
    export default {
      name: 'ElBreadcrumbItem',
      props: {
        to: {},
        replace: Boolean
      },
      data() {
        return {
          separator: '',
          separatorClass: ''
        };
      },
  
      inject: ['elBreadcrumb'],
  
      mounted() {
        this.separator = this.elBreadcrumb.separator;
        this.separatorClass = this.elBreadcrumb.separatorClass;
        const link = this.$refs.link;
        link.setAttribute('role', 'link');
        link.addEventListener('click', _ => {
          const { to, $router } = this;
          if (!to || !$router) return;
          this.replace ? $router.replace(to) : $router.push(to);
        });
      }
    };
  </script>