一提到分享相信PC端项目写多的小伙伴都挺头疼的,我们一般都觉得用二维码实现最方便
但这是在开发微信小程序,实现个好友分享还不容易吗?
在wxml中定义一个分享触发的按钮
<button open-type = "share">分享</button>
open-type = "share"很重要
然后在js中定义分享方法
onShareAppMessage: function(res) {
//let users = wx.getStorageSync('user');
if (res.from === 'button') {
}
return {
title: '分享的标题 例如 快快乐乐',
path: '分享的路径 例如 /pages/tuan/index',
success: function(res) {
console.log(res);
}
}
}