阅读 59

Vue怎么实现点击按钮将内容复制到剪贴板

<div class="dd">
  {{ orderInfo.orderNo || "暂无" }}
  <span class="td-copy-status" @click="handleCopy(orderInfo.orderNo)">
    复制
  </span>
</div>
复制代码
//复制
handleCopy(data) {
  let oInput = document.createElement("input");
  oInput.value = data;
  document.body.appendChild(oInput);
  oInput.select();
  document.execCommand("Copy");
  this.$message({
    message: "复制成功",
    type: "success"
  });
  oInput.remove();
},
复制代码

image.png

文章分类
前端
文章标签