Merge pull request #679 from kingxjs/main
fix: use document to build input fix copy command
This commit is contained in:
@@ -49,8 +49,18 @@ export async function copy(text) {
|
|||||||
try {
|
try {
|
||||||
await navigator.clipboard.writeText(text);
|
await navigator.clipboard.writeText(text);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
okay = false;
|
try {
|
||||||
console.error(e);
|
// 构建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;
|
||||||
|
console.error(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return okay;
|
return okay;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user