Closed hulang closed 3 years ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Hey, tried to reproduce the issue, but not sure what is the expected result. data-clipboard-text
is called as soon as data-clipboard-action
is triggered, so at least, the library is working as expected. Could you please create a https://jsfiddle.net/ demo with the problem? Closing the issue for now, but feel free to reopen as soon as you have a demo. Thx!
html code
<b class="kefu_wx auto_copy" data-clipboard-text="17774411177" data-clipboard-action="copy" data-tp="1">17774411177</b>
js code
$(function () { $.getScript('/js/clipboard.js', function () { var clipboard = new ClipboardJS('.auto_copy'); clipboard.on('success', function (e) { var copyObj = e.trigger; // get Attr var showPop = copyObj.dataset; // get test var text = e.text; e.clearSelection(); // console console.log('clipboard:' + text); }); clipboard.on('error', function (e) { var copyObj = e.trigger; var showPop = copyObj.dataset; if (showPop.tp == 1) { alert('请选择“微信”进行复制!'); } if (showPop.tp == 2) { alert('请选择“电话”进行复制!'); } }); }); });