复制内容到剪贴板怎么实现

动态 未结 1 3058
狼族烟熏
VIP1 2023-03-29 19:17:33
悬赏:0F币
复制内容到剪贴板怎么实现
回帖
  • 2024-09-10 01:18:16
    copy: { type: 'even', class: 'layui-btn-xs layui-btn-warm', icon: 'layui-icon-add-circle-fine', url: '#', text: __('Copy'), title: __('Copy'), full:0, width:'', height:'', hidden:false, callback:async function (obj, row) { var url = row.data.code console.log(url) var textarea = document.createElement('textarea'); textarea.value = url; document.body.appendChild(textarea); textarea.select(); try { var successful = document.execCommand('copy'); var msg = successful ? '成功' : '失败'; console.log('链接已复制到剪贴板' + msg); alert("链接已复制到剪贴板"); } catch (err) { console.log('无法复制', err); alert("无法复制"); } document.body.removeChild(textarea); }, },
    0 回复
本周热议