Wx-小程序-长按复制文本

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
                });
            }
        });
    },
原文地址:https://www.cnblogs.com/yangchin9/p/11158377.html