让微信内置浏览器兼容clipboard.js 复制粘贴 ios 安卓

时间:2021-09-05 06:47:40

<!--js copy事件-->
<script type="text/javascript" src="/static/js/clipboard.min.js" ></script>
<li>
<p>卡号-01:<span><input id="l1234567890" type="text" value="1234567890" readonly></span><button class="btnClipboard" data-clipboard-action="copy" data-clipboard-target="#l1234567890">复制</button></p>
<p>密码-01:
<span class="pass_mi">******</span>
<span class="pass_show">显示</span>
<span class="pass_num"><input id="l098765" type="text" value="098765" readonly></span>
<span class="pass_copy">
<button class="btnClipboard" data-clipboard-action="copy" data-clipboard-target="#l098765">复制</button>
</span>
</p>
</li>
    var clipboard = new ClipboardJS('.btnClipboard');
clipboard.on('success', function (e) {
layer.open({
content: '复制成功'
,skin: 'msg'
,time: 2 //2秒后自动关闭
});
});
clipboard.on('error', function (e) {
layer.open({
content: '请手动复制'
,skin: 'msg'
,time: 2 //2秒后自动关闭
});
});

让微信内置浏览器兼容clipboard.js 复制粘贴 ios 安卓

 
 
 
 
1, 点击框得是 button
2,id必须是英文开头
3, input设置readonly
 
就OK了, 测试支持 企业微信 ios 安卓 不会掉起键盘