wxml添加标题 open-type设为‘share’
<button open-type="share"></button>
点击就会触发下边的事件了
//js
onShareAppMessage: function () {
//console.log('aaa');
let that = this;
return {
title: 请填写分享标题, // 转发后 所显示的title
path: '请填写你要打开的路径', // 相对的路径
success: (res) => { // 成功后要做的事情
// console.log
wx.getShareInfo({
shareTicket: res.shareTickets[0],
success: (res) => {
that.setData({
isShow: true
})
},
fail: function (res) { console.log(res) },
complete: function (res) { console.log(res) }
})
},
fail: function (res) {
// 分享失败
console.log(res)
}
}
},