End mobile Click the button to copy the text content

<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 (); // Select the object

//document.execCommand("Cut","false",null);// browser Cut command execution

document.execCommand ( "Copy"); // Copy command execution browser

//oInput.className = "oInput";

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

alert ( "copy success");

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

},

Guess you like

Origin www.cnblogs.com/wlylove/p/11257159.html