Wx- applet long press to copy text

Original link: http://www.cnblogs.com/yangchin9/p/11158377.html

view:

<text bindlongtap='copy' data-name='{{name}}'>{{item.name}}</text>

js:

copy(e) {
        var that = this;
        wx.setClipboardData({
            data: e.currentTarget.dataset.name,
            success: function (res) {
                wx.showToast({
                    title: '复制成功',
                    icon: 'success',
                    duration: 1200,
                    mask: true
                });
            }
        });
    },

 

Reproduced in: https: //www.cnblogs.com/yangchin9/p/11158377.html

Guess you like

Origin blog.csdn.net/weixin_30438813/article/details/95282178