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/')
}

相关文章:

  • 2021-11-30
  • 2022-12-23
  • 2021-09-22
猜你喜欢
  • 2022-12-23
  • 2022-01-03
  • 2022-12-23
  • 2021-12-19
  • 2022-03-06
  • 2021-05-22
相关资源
相似解决方案