const textArea = document.createElement('textarea');
textArea.value = '想要复制的值';
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand('copy') ? alert('copy success') : alert('copy falied');
} catch (err) {
alert('copy falied');
}
document.body.removeChild(textArea);
网友评论