复制文字
import { Message } from 'element-ui'
<el-button @click="onCopyNo('123')">复制</el-button>
onCopyNo(text) {
const inputElement = document.createElement('input')
inputElement.style = 'position: absolute; left: -1000px; top: -1000px'
document.body.appendChild(inputElement)
inputElement.value = text
inputElement.focus()
inputElement.select()
document.execCommand('copy')
document.body.removeChild(inputElement)
Message.success('已复制到剪贴板')
}
不求大富大贵,但求一生平凡