一、弹出框点击复制,也可以点击直接复制即可,根据自己需求修改

<view bindtap="copyUrl" data-url="{{item.LinkUrl}}" >
...
</view>
copyUrl: function (e) {
    wx.showModal({
        title: '这是一个外部链接',
        content: '小程序暂不支持打开非业务域名的外部链接,可点击复制链接后在浏览器中粘贴查看',
        confirmText: '复制链接',
        success(res) {
            if (res.confirm) {
                console.log('用户点击确定')
                wx.setClipboardData({
                    data: e.currentTarget.dataset.url,  //文本内容
                    success: function (res) {
                        wx.getClipboardData({
                            success: function (res) {
                                wx.showToast({
                                    title: '链接复制成功'
                                })
                            }
                        })
                    }
                })
        
            } else if (res.cancel) {
                console.log('用户点击取消')
            }
        }
    })

}


0/300
全部评价