效果图 HTML代码 <div>链接:<span style="color: #FF8A21" @click="CopyUrl" id="copyId"> https://blog.csdn.net/qq_51463650?spm=1000.2115.3001.5343</span> </div> 复制方法 const CopyUrl = () => {let url = "https://blog.csdn.net/qq_51463650?spm=1000.2115.3001.5343";if (!url) return showToast('复制失败!')let copyDom = document.getElementById('copyId')copyDom.innerText = url//创建选中范围let range = document.createRange()range.selectNode(copyDom)//移除剪切板中内容window.getSelection().removeAllRanges()//添加新的内容到剪切板window.getSelection().addRange(range)//复制let successful = document.execCommand('copy')if (successful) {showToast('复制成功!')} else {showToast('复制失败!')}}