【JS】copy剪切板复制粘贴
const textarea = document.createElement("textarea");
textarea.setAttribute("readonly", true);
textarea.value = '传入的值';
document.body.appendChild(textarea);
textarea.setSelectionRange(0, textarea.value.length);
textarea.select();
if (document.execCommand("copy")) {
this.$Message.success("复制成功");
} else {
this.$Message.error("复制失败");
}
document.body.removeChild(textarea);