翻遍了搜索找到了clipboard.js
真香!
有个列表
每个行都有个按键
点击这个按键复制这一行的制定内容
或者复制这个按钮里的指定值
具体格式可以看下:https://bt.18sui.net
小尾巴我就菜鸡一枚 https://18sui.net炮兵学院
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('复制完成') })
@胡椒舰长,太高级了没看懂 小尾巴我就菜鸡一枚 https://18sui.net炮兵学院
@卷心菜,目测是装了火绒的且把状态栏设置在上边的并且打开了webStorm的win10系统. 红米Note4超高配版(银色)
@布偶, 大致思路就是 使用copyText函数创建了一个可以编辑的文本框, 并且设置其样式为"假装看不见", 设置其内容为你要复制的文本, 然后设置光标全选刚才的文本框内容, 执行系统copy命令, 复制结束后 做一下善后处理. 红米Note4超高配版(银色)
copyText
copy
调用方式