<template>
  <view class="field-copy" @click.stop="onCopy">
    <slot></slot>
    <view class="img">
      <image src="/static/copy-icon.png"></image>
    </view>
  </view>
</template>

<script>
export default {
	name:'fieldCopy',
  props: {
    value: [String, Number]
  },
  methods: {
    // 复制
    onCopy: async function () {
      if (this.value) {
        uni.setClipboardData({
          data: this.value,
          success: function () {
            uni.showToast({ icon: 'success', title: '已复制' });
          },
        });
      }
    },
  },
};
</script>

<style lang="scss">
.field-copy {
  display: inline-block;
  min-width: 40upx;
  .img {
    display: inline-block;
    width: 26rpx;
    height: 26rpx;
    margin-left: 8rpx;
    image {
	    width: 100%;
	    height: 100%;
      vertical-align: middle;
    }
  }
}
</style>
