copy(){//点击复制
let _this =this;
document.addEventListener('copy', save); // 监听浏览器copy事件
document.execCommand('copy'); // 执行copy事件,这时监听函数会执行save函数。
document.removeEventListener('copy', save); // 移除copy事件
// 保存方法
function save(event) {
event.clipboardData.setData('text/plain', 复制的内容); // 剪贴板内容设置
event.preventDefault();
}
alter('内容已经复制');
},
js实现代码复制
最新推荐文章于 2023-11-21 09:57:33 发布