使用一个不展示的input
标签来模拟复制功能,参考 document.execCommand。
function copyUrl() {
var URL = Math.random();
console.log(URL);
var oInput = document.createElement('input');
oInput.value = URL;
document.body.appendChild(oInput);
oInput.select();
document.execCommand("Copy");
oInput.remove();
}
现在去调用这个copyUr
函数,找个地方ctr+v
看看效果吧。
网友评论