【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 @   努力挣钱的小鑫  阅读(40)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起