//author limenghui created in 2018.7.26
const JsCopy={
//原生js复制内容到复制板
makeCopy(txt){
const input = document.createElement('input');
//防止ios点击复制时屏幕下方会出现白屏抖动,仔细看是拉起键盘又瞬间收起
input.setAttribute('readonly', 'readonly');
input.setAttribute('value',txt)
document.body.appendChild(input);
let sysMsg=this.getOs();
console.log(sysMsg,'检测版本信息')
//input.select() 在ios下并没有选中全部内容,使用以下来选中内容
if(sysMsg == 'ios'){
//ios复制
let obj=this.iosCopy(txt);
this.destoryNode(obj.html,obj.style)
//input.setSelectionRange(0,input.value.length);
}else if(sysMsg == 'android'){
//android选择复制内容
input.select(txt);
}
document.execCommand('copy',true);
document.body.removeChild
原生jscopy兼容ios和安卓
最新推荐文章于 2023-03-26 19:16:14 发布