vue中点击按钮复制内容

<el-button type="primary" round size="mini" @click="copyUrl">复制url</el-button>   
//js
    copyUrl() {
      const input = document.createElement('input')
      document.body.appendChild(input)
      input.setAttribute('value',"这里可以写变量或者要复制的字符串内容")
      input.select()
      if (document.execCommand('copy')) {
        document.execCommand('copy')
      }
      document.body.removeChild(input)
    
原文地址:https://www.cnblogs.com/shuen/p/9517372.html