Function: Click the button to copy the content and paste it in the input box.
<el-input v-model="text"></el-input>
<el-button @click="copy">复制</el-button>
copy(){
let ipt = document.createElement('input')
ipt.value = '复制内容'
document.body.appendChild(ipt)
ipt.select()
document.execCommand('Copy')
ipt.remove()
this.$message({
message: '复制成功',
type: 'success'
})
}
Reference link: js implements copy function