第一次提交
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
/**一键复制 */
|
||||
// import { Message } from "element-ui";
|
||||
import {showMsg} from "@/utils/showMsg";
|
||||
function fallbackCopyToClipboard(text) {
|
||||
const textarea = document.createElement("textarea");
|
||||
textarea.value = text;
|
||||
textarea.style.position = "fixed";
|
||||
document.body.appendChild(textarea);
|
||||
textarea.select();
|
||||
|
||||
try {
|
||||
document.execCommand("copy");
|
||||
// alert('复制成功(降级方案)!');
|
||||
showMsg("已复制到剪切板", "success");
|
||||
} catch (err) {
|
||||
console.error("降级复制失败:", err);
|
||||
// alert('复制失败,请手动复制!');
|
||||
showMsg("复制失败,请手动复制!", "error");
|
||||
}
|
||||
|
||||
document.body.removeChild(textarea);
|
||||
}
|
||||
export default fallbackCopyToClipboard;
|
||||
Reference in New Issue
Block a user