html
<span class=" wz" th:text="${card.wechat}" id="wechat" style="font-size: 35px"></span>
<div class="a-w wxh">
<button type="button" class="weui-btn weui-btn_default" onclick="fuwei()">复制微信号</button>
</div>
js
function fuwei() {
if (navigator.userAgent.match(/(iPhone|iPod|iPad|Android);?/i)) {
window.getSelection().removeAllRanges();
var Url2 = document.getElementById("wechat");
var range = document.createRange();
range.selectNode(Url2);
window.getSelection().addRange(range);
var successful = document.execCommand('copy');
window.getSelection().removeAllRanges();
} else {
var Url2 = document.getElementById("wechat");
Url2.select();
document.execCommand("Copy");
}
}