复制文本功能
copyText(){ const textarea = document.createElement('textarea'); textarea.readOnly = 'readonly'; // textarea.style.position = 'absolute'; // textarea.style.left = '-9999px'; textarea.value = "文字内容"; document.body.appendChild(textarea); textarea.select(); textarea.setSelectionRange(0, textarea.value.length); const result = document.execCommand('Copy'); if (result) { this.$message.success("复制成功"); } document.body.removeChild(textarea); }