<template>
  <div class="th-copy">
    <div class="th-copy-text" :title="text">{{text || placeholder}}</div>
    <Tooltip content="复制" placement="top">
      <div :class="['th-copy-btn', {disabled:!text}]" @click="copyText">
        <Icon custom="iconfont icon-clipboard" size="16" color="#ffffff"/>
      </div>
    </Tooltip>
  </div>
</template>

<script>
export default {
  props: {
    text: {
      type: String,
      default: ''
    },
    placeholder: {
      type: String,
      default: '暂无数据'
    }
  },
  methods: {
    copyText() {
      if (!this.text) {
        return
      }
      this.$Copy({
        text: this.text
      })
    }
  }
}
</script>