实现复制dom节点中的内容:
function copyText (ele) { try { let selection = window.getSelection() if (selection.rangeCount > 0) selection.removeAllRanges() let range = document.createRange() range.selectNodeContents(ele) selection.addRange(range) document.execCommand("copy") selection.removeAllRanges() return Promise.resolve({success: true, message: '复制成功'}) } catch (error) { return Promise.resolve({success: false, message: '复制失败'}) } }