// 是否支持复制
export const isSupportCopy = ((!!document.queryCommandSupported) && document.queryCommandSupported('copy'));
const copyTempElement = document.createElement('textarea');
copyTempElement.setAttribute('style', 'margin:0;padding:0;width:0;height:0;position:absolute;');
document.body.appendChild(copyTempElement);
// 复制文本到剪切板
export function copyText(text) {
let succeeded;
try {
copyTempElement.value = text;
copyTempElement.select();
succeeded = document.execCommand('copy');
} catch (err) {
succeeded = false;
}
return succeeded;
}
继续阅读与本文标签相同的文章
-
elasticsearc使用指南之ES管道聚合(Pipeline Aggregation)
2026-05-19栏目: 教程
-
别再吐槽地铁拥堵,线网规划现在由你大展身手
2026-05-19栏目: 教程
-
Elasticsearch Index Setting一览表
2026-05-19栏目: 教程
-
Java后端面经总结:拿下蚂蚁金服美团头条 offer 秘诀
2026-05-19栏目: 教程
-
Elasticsearch Index Aliases详解
2026-05-19栏目: 教程
