<template>
  <div class="mch-copy">
    <div class="mch-copy-text" :title="text">{{text || placeholder}}</div>
    <Tooltip content="复制" placement="top">
      <div :class="['mch-copy-btn', {disabled:!text}]" @click="copyText">
        <Icon type="md-copy" 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>