使用navigator.clipboard.writeText(value);相比以前更加簡潔,采用promise實現(xiàn)
//舊:
let oInput = document.createElement('input');
oInput.value = value;
document.body.appendChild(oInput);
oInput.select(); // 選擇對象;
document.execCommand("Copy"); // 執(zhí)行瀏覽器復制命令
this.$Message.success('復制成功');
oInput.remove()
//新:
navigator.clipboard.writeText(value).then(() => {
this.$Message.success('復制成功');
});