Browse Source

fix: compatibility with vetur

https://github.com/PanJiaChen/vue-element-admin/commit/fc26c3106fefda7ff80afdc8bcad06f0b1ef2909
潘嘉晨 4 years ago
parent
commit
aff349a863
1 changed files with 16 additions and 9 deletions
  1. 16 9
      src/layout/components/Sidebar/Link.vue

+ 16 - 9
src/layout/components/Sidebar/Link.vue

@@ -1,7 +1,5 @@
1
-
2
 <template>
1
 <template>
3
-  <!-- eslint-disable vue/require-component-is -->
4
-  <component v-bind="linkProps(to)">
2
+  <component :is="type" v-bind="linkProps(to)">
5
     <slot />
3
     <slot />
6
   </component>
4
   </component>
7
 </template>
5
 </template>
@@ -16,19 +14,28 @@ export default {
16
       required: true
14
       required: true
17
     }
15
     }
18
   },
16
   },
17
+  computed: {
18
+    isExternal() {
19
+      return isExternal(this.to)
20
+    },
21
+    type() {
22
+      if (this.isExternal) {
23
+        return 'a'
24
+      }
25
+      return 'router-link'
26
+    }
27
+  },
19
   methods: {
28
   methods: {
20
-    linkProps(url) {
21
-      if (isExternal(url)) {
29
+    linkProps(to) {
30
+      if (this.isExternal) {
22
         return {
31
         return {
23
-          is: 'a',
24
-          href: url,
32
+          href: to,
25
           target: '_blank',
33
           target: '_blank',
26
           rel: 'noopener'
34
           rel: 'noopener'
27
         }
35
         }
28
       }
36
       }
29
       return {
37
       return {
30
-        is: 'router-link',
31
-        to: url
38
+        to: to
32
       }
39
       }
33
     }
40
     }
34
   }
41
   }