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
                });
            }
        });
    },

 

posted @ 2019-07-09 16:39  yangchin9  阅读(596)  评论(0编辑  收藏  举报