PHP群:95885625 Hbuilder+MUI群:81989597 站长QQ:634381967
    您现在的位置: 首页 > 开发编程 > 编程杂谈 > 正文

    layui 点击链接复制内容到剪切板

    作者:admin来源:网络浏览:时间:2020-11-20 11:15:24我要评论
    导读:layui 点击链接复制内容到剪切板


    1. var tableObj = table.render({ 
    2.             id: 'list_table'
    3.             elem: '#list_table'
    4.             url: ''
    5.             align: "center"
    6.             cols: [[ //表头 
    7.                 {type: 'checkbox'}, 
    8.                 {type: 'numbers', title: '序号',width:80}, 
    9.                 { 
    10.                     field: 'lock', title: '链接', align: 'center', templet: function (d) { 
    11.                     return   '<a href="javascript:;" data-clipboard-text="" class="font-primary" lay-event="share">分享</a>'
    12.                 }, unresize: true, align: 'center' 
    13.                 } 
    14.             ]] 
    15.         }); 


     

    1. table.on('tool(mainList)'function (obj) { 
    2.         var data = obj.data; 
    3.         var layEvent = obj.event; 
    4.         if (layEvent === 'share') { 
    5.                   $(".font-primary").attr("data-clipboard-text",data.id); 
    6.                   var clipboard = new ClipboardJS('.font-primary'); 
    7.                   clipboard.on('success'function(e) { 
    8.                       alert('复制成功'); 
    9.                       clipboard.destroy();  //解决多次弹窗 
    10.                       e.clearSelection(); 
    11.                   }); 
    12.          } 
    13.     }) 

     

    转载请注明(B5教程网)原文链接:https://b5.mxunkeji.com/content-74-6439-1.html