let url = 复制的内容;
var input = document.createElement('input');
document.body.appendChild(input);
input.setAttribute('value', url);//复制的内容
input.select();
document.execCommand("copy"); // 执行浏览器复制命令
if (document.execCommand('copy')) {
document.execCommand('copy');
this.modelBtn()
this.$refs.copy.style.zIndex = 999999;
this.$refs.copy.style.opacity = 1;
setTimeout(() => {
this.$refs.copy.style.zIndex = 0;
this.$refs.copy.style.opacity = 0;
}, 1000);
}
document.body.removeChild(input);
复制内容到剪贴板
最新推荐文章于 2024-08-20 12:03:01 发布