uniapp点击按钮复制链接

<text style="color: #0075F7;">{{completeUrl}}</text>
<u-button type="primary" @click="copyUrl(completeUrl)">复制URL</u-button>

  

        copyUrl(url) {
                uni.showModal({
                    content: url,
                    confirmText: '复制内容',
                    success: () => {
                        uni.setClipboardData({
                            data: url,
                            success: function() {
                                uni.hideToast({
                                    title: '复制成功',
                                    duration: 2000,
                                    icon: 'none'
                                });
                            },
                            fail: function(err) {
                                uni.showToast({
                                    title: '复制失败',
                                    duration: 2000,
                                    icon: 'none'
                                });
                            }
                        });
                    }
                });
            },

 

posted @ 2022-03-22 17:32  热爱前端的5号机器  阅读(1368)  评论(0编辑  收藏  举报