js复制文本信息 兼容ios和安卓
// 复制文字
copyBtn(txt){
var input = document.createElement(“input”);
input.value = txt;
document.body.appendChild(input);
input.select();
input.setSelectionRange(0, input.value.length), document.execCommand(‘Copy’);
document.body.removeChild(input);
console.log(“复制成功”, txt);
}
只需要调用这个方法把需要复制的文字传进去就可以了