默认情况下分享是灰色的

只要重写onShareAppMessage方法就可以实现分享功能,分享有两种情况
一、一种是点击右上角三个点分享:判断res.from === 'menu'
onShareAppMessage (res) {
console.log(res);
if (res.from === 'menu') { // button:来自页面内分享按钮
return {
title: '标题',
path: '/pages/index/index',
imageUrl: '/static/register/img.jpg'
}
}
},
二、按钮分享:判断res.from === 'button',还需要在按钮上添加open-type="share"
<button type="default" open-type="share">分享</button>
在微信小程序中,默认的分享功能可能是灰色的,但可以通过重写onShareAppMessage方法来激活。对于右上角菜单的分享,需检查res.from是否为menu,并返回分享配置。若要设置页面内按钮分享,需在按钮上添加open-type=share属性。
1189

被折叠的 条评论
为什么被折叠?



