Explorar o código

fix copy-text

wolyshaw %!s(int64=4) %!d(string=hai) anos
pai
achega
1915caadc2
Modificáronse 1 ficheiros con 7 adicións e 2 borrados
  1. 7 2
      src/components/copy-text/index.vue

+ 7 - 2
src/components/copy-text/index.vue

@@ -1,7 +1,7 @@
 <template>
-  <span class="copy" v-if="$slots.default || text">
+  <span class="copy" v-if="textContent">
     <slot/>{{text}}
-    <i v-if="!!text" @click="copyText" title="复制" class="el-icon-document-copy"></i>
+    <i v-if="!!textContent" @click="copyText" title="复制" class="el-icon-document-copy"></i>
   </span>
 </template>
 
@@ -20,6 +20,11 @@ export default {
       default: true
     }
   },
+  computed: {
+    textContent() {
+      return this.$slots.default || this.text
+    }
+  },
   methods: {
     copyText() {
       const slot = this.$slots.default || []