系统自带的复制功能
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <textarea id="copy">acret</textarea> <button type="primary" onclick="copy()">点击复制</button> </body> <script type="text/javascript"> function copy() { console.log('aaa') var e = document.getElementById("copy"); e.select(); // 选择对象 document.execCommand("Copy"); // 执行浏览器复制命令 alert("复制成功!"); } </script> </html>