备份

vue element-ui 复制文本到粘贴板

来源:https://www.cnblogs.com/lwlblog/p/13178307.html

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

 

posted @ 2022-02-21 16:14  菜鸡记录  阅读(12)  评论(0)    收藏  举报