美文网首页
前端复制

前端复制

作者: 宏_4491 | 来源:发表于2020-08-17 14:16 被阅读0次

    前端的复制功能

      <span class="copy" @click="autoCopyUrl()" ref="invitUrl">复制</span>
    
        autoCopyUrl() {
          const input = document.createElement('input')
          const url = this.$refs.invitUrl.innerText
          document.body.appendChild(input)
          input.setAttribute('value', url)
          input.select()
          if (document.execCommand('copy')) {
            document.execCommand('copy')
            this.$message.success('复制分享链接成功')
          }
          document.body.removeChild(input)
        }
    

    相关文章

      网友评论

          本文标题:前端复制

          本文链接:https://www.haomeiwen.com/subject/aqkqjktx.html