var tableObj = table.render({ id: 'list_table', elem: '#list_table', url: '', align: "center", cols: [[ //表头 {type: 'checkbox'}, {type: 'numbers', title: '序号',80}, { field: 'lock', title: '链接', align: 'center', templet: function (d) { return '<a href="javascript:;" data-clipboard-text="" class="font-primary" lay-event="share">分享</a>'; }, unresize: true, align: 'center' } ]] });
table.on('tool(mainList)', function (obj) { var data = obj.data; var layEvent = obj.event; if (layEvent === 'share') { $(".font-primary").attr("data-clipboard-text",data.id); var clipboard = new Clipboard('.font-primary'); clipboard.on('success', function(e) { alert('复制成功'); clipboard.destroy(); //解决多次弹窗 e.clearSelection(); }); } })
下载:clipboard.js
链接:https://pan.baidu.com/s/1LNNmA5KAwI3S1K31oLDo7Q
提取码:iigd
转载:https://blog.csdn.net/jia__xin/article/details/89173662