布局
button介绍https://uniapp.dcloud.io/component/button
<button class="share-now" open-type="share">去分享</button>
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'
})
}
}
}
如果是分享列表中的其中一个的处理

//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'
})
}
}
},
网友评论