📖微信小程序分享给朋友与分享到朋友圈函数
前言
代码
将下面代码放到对应页面的JS文件中,并修改对应参数即可
onShareAppMessage: function (res) {//转发给朋友
if (res.from === 'button') {
// 来自页面内转发按钮
console.log(res.target)
}
console.log(this.data)
return {
title: "网站名",
path: '/pages/index/index',//点击分享链接跳转的路径
imageUrl: this.data.titlepic //分享展示的图片
}
},
onShareTimeline: function (res) {//转发到朋友圈
if (res.from === 'button') {
console.log(res.target)
}
return {
title: "网站名",
path: '/pages/index/index',
imageUrl: this.data.titlepic
}
}



