Browse Source

fix copy-text

wolyshaw 4 years ago
parent
commit
1915caadc2
1 changed files with 7 additions and 2 deletions
  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 || []