前端点击复制内容

function copy() {
        const range = document.createRange();
        range.selectNode(document.getElementById('wxNumber'));//需要复制的内容
        const selection = window.getSelection();
        if(selection.rangeCount > 0) selection.removeAllRanges();
        selection.addRange(range);
        document.execCommand('copy');
        alert("复制成功!打开微信添加好友");
}
原文地址:https://www.cnblogs.com/edwardwzw/p/14240166.html