document.execCommand("copy")复制链接或文本


<div v-if="type != 2" ref="qrcode" :class="['link-code',[manuscript.manuscriptType==2?'link-code-poster':'']]" @click="copyLink" @mouseenter="scaleMax" @mouseleave="scaleMin"></div>
<input id="copyLinkInput" class="copy-input"/>
.link-code {
  position: absolute;
  bottom: 20px;
  left: 0;
  width: 70px;
  height: 70px;
}
.copy-input {
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0;
  z-index: -10;
}
    // 点击二维码复制链接
    copyLink() {
      var _this = this;
      var $linkInput = $('#copyLinkInput');

      $linkInput.val(_this.previewUrl);
      $linkInput.select();
      document.execCommand("copy");
      setTimeout(function () {
          _this.$message.success('复制链接成功!')
      }, 100)
    },




免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM