欢迎光临我的博客,我是努力挣钱的小鑫!目前|

努力挣钱的小鑫

园龄:4年10个月粉丝:36关注:8

【JavaScript】js 处理复制函数实现

export const copyText = (text: string) => {
  const input = document.createElement('input');
  input.setAttribute('readonly', 'readonly');
  input.setAttribute('value', text);
  document.body.appendChild(input);
  input.select();
  input.setSelectionRange(0, 9999);
  if (document.execCommand('copy')) {
    document.execCommand('copy');
    ElMessage.success('复制成功');
  }
  document.body.removeChild(input);
};
posted @   努力挣钱的小鑫  阅读(42)  评论(0编辑  收藏  举报
历史上的今天:
2022-07-11 【前端可视化】Canvas 和 SVG 区别
2022-07-11 【Vue】前端人脸识别框架 tracking.js 活体检测/拍照在 vue2 的使用
2022-07-11 【Vue】NavBar 顶部弹窗点击弹窗外部区域关闭弹窗实现
2021-07-11 【个人杂谈】每天坚持看书能否真的提升自己?
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起