function xyz_copy(str){
var w = document.createElement('input');
w.value = str;
document.body.appendChild(w);
w.select();
document.execCommand("Copy");
w.style.display='none';
}
xyz_cpoy("aaa")
直接上代码
创建input元素,给input传值,将input放入html里,选择input
再调用浏览器的复制命令
最后隐藏input元素