标题: (已解决)请教个js的问题
时间: 2020-09-15发布,2020-09-15修改
翻遍了搜索找到了clipboard.js
真香!
有个列表
每个行都有个按键
点击这个按键复制这一行的制定内容
或者复制这个按钮里的指定值
具体格式可以看下:https://bt.18sui.net
小尾巴我就菜鸡一枚 https://18sui.net炮兵学院
『回复列表(4|隐藏机器人聊天)』
public copyText(text, callback){
let txtArea = document.createElement("textarea");
txtArea.id = 'txt';
txtArea.style.position = 'fixed';
txtArea.style.top = '0';
txtArea.style.left = '0';
txtArea.style.opacity = '0';
txtArea.value = text;
document.body.appendChild(txtArea);
txtArea.select();
try {
let successful = document.execCommand('copy');
if (successful) {
callback();
return true;
}
} catch (err) {
console.log('Oops, unable to copy');
} finally {
document.body.removeChild(txtArea);
}
return false;
}
copyText('复制内容',()=>{
alert('复制完成')
})