Blame view

src/components/anchor/anchor-link.vue 990 Bytes
43513f70   zhigang.li   add anchor component
1
2
  <template>
  	<div :class="anchorLinkClasses">
3fe51bfc   梁灏   update Anchor
3
          <a :class="linkTitleClasses" :href="href" :data-href="href" @click.prevent="goAnchor" :title="title">{{ title }}</a>
43513f70   zhigang.li   add anchor component
4
5
6
7
          <slot></slot>
      </div>
  </template>
  <script>
43513f70   zhigang.li   add anchor component
8
9
  export default {
      name: 'AnchorLink',
c69f8ff5   梁灏   update Anchor
10
      inject: ['anchorCom'],
43513f70   zhigang.li   add anchor component
11
12
13
14
15
16
17
18
19
20
21
22
23
      props: {
          href: String,
          title: String
      },
      data () {
          return {
              prefix: 'ivu-anchor-link'
          };
      },
      computed: {
          anchorLinkClasses () {
              return [
                  this.prefix,
c69f8ff5   梁灏   update Anchor
24
                  this.anchorCom.currentLink === this.href ? `${this.prefix}-active` : ''
43513f70   zhigang.li   add anchor component
25
26
27
28
29
30
              ];
          },
          linkTitleClasses () {
              return [
                  `${this.prefix}-title`
              ];
43513f70   zhigang.li   add anchor component
31
32
33
34
          }
      },
      methods: {
          goAnchor () {
c69f8ff5   梁灏   update Anchor
35
              this.anchorCom.turnTo(this.href);
43513f70   zhigang.li   add anchor component
36
          }
4556cfa8   zhigang.li   fixed bug of anch...
37
38
39
      },
      mounted () {
          this.$nextTick(() => {
c69f8ff5   梁灏   update Anchor
40
              this.anchorCom.init();
4556cfa8   zhigang.li   fixed bug of anch...
41
          });
43513f70   zhigang.li   add anchor component
42
43
44
      }
  };
  </script>