const result = "需要被复制的内容";
const input = document.createElement("input");
document.body.appendChild(input);
input.setAttribute("value", result);
input.select();
if (document.execCommand("copy")) {
alert("复制成功");
document.execCommand("copy");
}
document.body.removeChild(input);