方法1:瀏覽器
var oInput = document.getElementById('input'); oInput.select(); // 選擇對象 document.execCommand("Copy"); // 執行瀏覽器複製命令 message.success("複製成功", 1);
方法2:app
var dummy = document.createElement('input'); text = window.location.href; document.body.appendChild(dummy); dummy.value = text; dummy.select(); // 選擇對象 document.execCommand('copy'); // 執行瀏覽器複製命令 document.body.removeChild(dummy);