美文网首页
uni-app 实现在小程序内分享小程序

uni-app 实现在小程序内分享小程序

作者: hao_developer | 来源:发表于2021-04-16 11:14 被阅读0次

布局
button介绍https://uniapp.dcloud.io/component/button

<button class="share-now" open-type="share">去分享</button>

方法(页面生命周期)https://uniapp.dcloud.io/collocation/frame/lifecycle?id=%e9%a1%b5%e9%9d%a2%e7%94%9f%e5%91%bd%e5%91%a8%e6%9c%9f

    onShareAppMessage(res) {
            return{
                title: "xxx欢迎你",
                path: "pages_product/product_details",
                imageUrl: "http://b267.photo.store.qq.com/psb?/V119XNCu1CAvfv/6Brnux0r2VHuu*2VDbY0AUDPOQ*nXcuRTE6c91zUY4w!/b/dAsBAAAAAAAA&bo=gALgAYAC4AEFGTo!&rf=viewer_4",
                desc: "xxx哈哈哈",
                content: "xxx集团",
                success(res){
                    uni.showToast({
                        title:'分享成功'
                    })
                },
                fail(res){
                    uni.showToast({
                        title:'分享失败',
                        icon:'none'
                    })
                }
            }
        }

如果是分享列表中的其中一个的处理

image.png
//button要添加点击事件,要不然获取不到点击的是哪个
<button @tap.stop="shareClick(index)"  open-type="share" class="share-btn" :key="index"></button>

onShareAppMessage(res) {
            console.log("分享", res)
            console.log("第几个", res.target.dataset.eventOpts[0][1][0][1][0])
            return{
                title: "欢迎你",
                path: "pages_product/product_details",
                imageUrl: this.shareImgUrl,
                desc: "哈哈哈",
                content: "哈哈哈集团",
                success(res){
                    uni.showToast({
                        title:'分享成功'
                    })
                },
                fail(res){
                    uni.showToast({
                        title:'分享失败',
                        icon:'none'
                    })
                }
            }
        },

相关文章

网友评论

      本文标题:uni-app 实现在小程序内分享小程序

      本文链接:https://www.haomeiwen.com/subject/isxelltx.html