【Ant Design】-button 添加文本复制功能

1. 添加button按钮

<a-button type="primary" size="small" @click="onCopy(viewDetailForm.val)">复制</a-button>

2. method中添加copy方法

onCopy(certB64){
  let oInput = document.createElement('input')
  oInput.value = certB64;
  document.body.appendChild(oInput)
  oInput.select() // 选择对象
  document.execCommand("Copy") // 执行浏览器复制命令
  this.$message.success("复制成功");
  oInput.remove()
}

以上代码,支持Element-UI,Ant Design两种前端UI框架。

posted @ 2020-09-23 12:15  多搞学习少搞事情  阅读(4102)  评论(0编辑  收藏  举报