copy(data) {
let url = data
let oInput = document.createElement('input')
oInput.value = url
document.body.appendChild(oInput)
oInput.select() // 選擇對象
document.execCommand("Copy") // 執行瀏覽器復制命令
this.$message({
message: '復制成功',
type: 'success'
})
oInput.remove()
}
使用方法
copyLink() {
this.copy('https://baidu.com/')
}