Commit e266bc91 by 迷糊虫 Committed by GitHub

使用原生document构建input再次尝试复制命令

parent 7da427c2
...@@ -49,9 +49,19 @@ export async function copy(text) { ...@@ -49,9 +49,19 @@ export async function copy(text) {
try { try {
await navigator.clipboard.writeText(text); await navigator.clipboard.writeText(text);
} catch (e) { } catch (e) {
try {
// 构建input 执行 复制命令
var _input = window.document.createElement("input");
_input.value = text;
window.document.body.appendChild(_input);
_input.select();
window.document.execCommand("Copy");
window.document.body.removeChild(_input);
} catch (e) {
okay = false; okay = false;
console.error(e); console.error(e);
} }
}
return okay; return okay;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment