点击按钮,复制对应的连接。

1.如图
在这里插入图片描述
2.实现

{ { fuzhi }} { { wenhao }}{ { idd }}

<button class=“btn” @click=“CopyUrl”>复制链接

CopyUrl(){
this.fuzhi2 = this.fuzhi+this.wenhao+this.idd // 这是我自定义的复制内容
console.log(this.fuzhi2)
var Url2 = this.$refs.input1.value
var oInput = document.createElement(“input”);
oInput.value = this.fuzhi2; //如果要复制input1中的内容,这里填Url2
document.body.appendChild(oInput);
oInput.select(); // 选择对象
document.execCommand(“Copy”); // 执行浏览器复制命令
oInput.className = “oInput”;
oInput.style.display = “none”;
}

猜你喜欢

转载自blog.csdn.net/WQzeus/article/details/109910040