const copyToClipboard = str => {
const el = document.createElement('textarea');
el.value = str;
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
};
点击执行此函数
来源:https://hackernoon.com/copying-text-to-clipboard-with-javascript-df4d4988697f
js 复制字符到剪切板
猜你喜欢
转载自www.cnblogs.com/shaoyang0123/p/12799913.html
今日推荐
周排行