Blame view

ruoyi-ui/src/layout/components/Sidebar/Link.vue 700 Bytes
46444bd0   RuoYi   RuoYi-Vue 1.0
1
  <template>

8a61b9fe   RuoYi   slidebar eslint报错优化
2
    <component :is="type" v-bind="linkProps(to)">

46444bd0   RuoYi   RuoYi-Vue 1.0
3
4
5
6
7
8
9
10
11
12
13
14
15
16
      <slot />

    </component>

  </template>

  

  <script>

  import { isExternal } from '@/utils/validate'

  

  export default {

    props: {

      to: {

        type: String,

        required: true

      }

    },

8a61b9fe   RuoYi   slidebar eslint报错优化
17
18
19
20
21
22
23
24
25
26
27
    computed: {

      isExternal() {

        return isExternal(this.to)

      },

      type() {

        if (this.isExternal) {

          return 'a'

        }

        return 'router-link'

      }

    },

46444bd0   RuoYi   RuoYi-Vue 1.0
28
    methods: {

8a61b9fe   RuoYi   slidebar eslint报错优化
29
30
      linkProps(to) {

        if (this.isExternal) {

46444bd0   RuoYi   RuoYi-Vue 1.0
31
          return {

8a61b9fe   RuoYi   slidebar eslint报错优化
32
            href: to,

46444bd0   RuoYi   RuoYi-Vue 1.0
33
34
35
36
37
            target: '_blank',

            rel: 'noopener'

          }

        }

        return {

8a61b9fe   RuoYi   slidebar eslint报错优化
38
          to: to

46444bd0   RuoYi   RuoYi-Vue 1.0
39
40
41
42
43
        }

      }

    }

  }

  </script>