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

·  阅读 919
<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

分类:
前端
标签:
收藏成功!
已添加到「」, 点击更改