移動端點擊按鈕復制文本內容


<div>
<p>邀請碼</p>
//
<p id="inviteCode" class="inviteCode">{{invite_code}}</p>
<input id="inviteCode" class="inviteCode" type="text" />
<p class="copy">復制</p>
</div>


copy() {

var Url2 = this.invite_code;

//var oInput = document.createElement("input");

var oInput = document.getElementById("inviteCode");

//oInput.value = Url2;

// document.body.appendChild(oInput);

oInput.select();// 選擇對象

//document.execCommand("Cut","false",null);// 執行瀏覽器剪切命令

document.execCommand("Copy");// 執行瀏覽器復制命令

//oInput.className = "oInput";

//oInput.style.display = "none";

alert("復制成功");

//console.log(document.execCommand("Copy"))

},


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM