美文网首页
js 点击复制链接

js 点击复制链接

作者: 逸笛 | 来源:发表于2021-01-14 17:50 被阅读0次

//封装的方法:

  copyUrl (url) {
    // 找到id为copyUrl的区域复制到剪切板
    var ele = document.getElementById('copyUrl')
    ele.value = url
    ele.select()
    document.execCommand('Copy')
  },
          <div class="sh-box">
              <input
                id="copyUrl"
                type="textarea"
                value="fileURL"
                placeholder="分享链接"
              ></el-input>
              <span @click="copyURL(fileURL)" class="copy-btn">复制</span>
            </div>
   copyURL (url) {
      this.$utils.copyUrl(url)
      this.$notify.success({
        title: '提示',
        message: '复制链接成功!'
      })
    }

相关文章

网友评论

      本文标题:js 点击复制链接

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