wolyshaw 4 лет назад
Родитель
Сommit
1915caadc2
1 измененных файлов с 7 добавлено и 2 удалено
  1. 7 2
      src/components/copy-text/index.vue

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

@@ -1,7 +1,7 @@
 <template>
 <template>
-  <span class="copy" v-if="$slots.default || text">
+  <span class="copy" v-if="textContent">
     <slot/>{{text}}
     <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>
   </span>
 </template>
 </template>
 
 
@@ -20,6 +20,11 @@ export default {
       default: true
       default: true
     }
     }
   },
   },
+  computed: {
+    textContent() {
+      return this.$slots.default || this.text
+    }
+  },
   methods: {
   methods: {
     copyText() {
     copyText() {
       const slot = this.$slots.default || []
       const slot = this.$slots.default || []