We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
js原生实现拷贝到剪贴板
The text was updated successfully, but these errors were encountered:
function copyText (text) { let input = document.createElement('input'); input.setAttribute('readonly', 'readonly'); input.setAttribute('value', text); document.body.appendChild(input); input.select(); // 不能少 if (!text || !text.length) { console.log('复制内容不能为空!'); return; } input.setSelectionRange(0, text.length); if (document.execCommand('copy')) { document.execCommand('copy'); console.log('复制成功!'); } else { console.log('复制失败!'); } document.body.removeChild(input); }
Sorry, something went wrong.
No branches or pull requests
js原生实现拷贝到剪贴板
The text was updated successfully, but these errors were encountered: