vue 复制链接功能

//复制链接
copyUrl(index) {
      if (this.couponList[index].status == 2) {
        this.$sweetalert.errorAlert("警告", "该优惠券暂不可用");
        return;
      }
      var id = this.couponList[index].couponId;
      var url =
        this.Global.url + "/BusinessCenter/CouponCollection?couponId=" + id;
      var oInput = document.createElement("input");
      oInput.value = url;
      document.body.appendChild(oInput);
      oInput.select(); // 选择对象
      document.execCommand("Copy"); // 执行浏览器复制命令
      oInput.className = "oInput";
      oInput.style.display = "none";
      this.$toastr.tipSuccess("复制成功","消息提示");
    }
  },

  

posted @ 2020-06-18 11:19  潇潇mini  阅读(2215)  评论(0编辑  收藏  举报