layui 點擊鏈接復制內容到剪切板


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM