點擊復制,就可以實現copy
<p class="inline-block">
<span >{{fenxiao.appSecret}}</span>
<span style="color: #0000FF;cursor: pointer" @click="copyAppSecret">復制</span>
</p>
copyAppSecret() {
let createInput = document.createElement("input");
createInput.value = this.fenxiao.appSecret;
document.body.appendChild(createInput);
createInput.select(); // 選擇對象
document.execCommand("Copy"); // 執行瀏覽器復制命令
createInput.style.display = "none";
this.$message({ message: "復制成功", type: "success" });
},
網上說的那種
let tt=document.getElementById("xxxx")
tt.select(); // 選擇對象
document.execCommand("Copy"); // 執行瀏覽器復制命令
這種不行

文本是沒有select
方法的,input才有 所以要先創建input元素,在添加值,在賦值,
親測有效,換成el-input就能行