积累-复制文本功能实现

222 阅读1分钟

1.复制文本功能实现

<span class="label">身份证号:</span>{{ applyRecordInfo.patient.idCard }}
  <el-tooltip
   class="item"
   effect="dark"
   content="复制"
   placement="top">
<i
  class="el-icon-copy-document"
  style="z-index: 99;position: relative;cursor: pointer"
  @click="handleCopy(applyRecordInfo.patient.idCard)"
></i>
</el-tooltip>

handleCopy(txt) {
      var aux = document.createElement("input");
      aux.setAttribute("value", txt);
      document.body.appendChild(aux);
      aux.select();
      document.execCommand("copy");
      document.body.removeChild(aux);
      this.$message({
        message: "复制成功",
        type: "success"
      });
    },