vue中點擊按鈕複製內容

<button @click="copyUrl">複製url</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)
相關文章
相關標籤/搜索