function copyNum(text){
var input = document.createElement('input');
input.setAttribute('readonly', 'readonly'); // 防止手机上弹出软键盘
input.setAttribute('value', text);
document.body.appendChild(input);
input.setSelectionRange(0, 9999);
input.select();//复制
var res = document.execCommand('copy');
document.body.removeChild(input);
layer.msg("复制成功",{time:1000});
return res;
}
参数text是想要复制的内容,直接可以使用此段代码即可