微信小程序的分享功能,在最新版庫的ide上已經不能拿到分享回調了,官方api也刪除了對應的回調函數,看樣子是砍掉了,不過真機測試還是可以的,話不多說,上代碼:
/* // 分享功能回調 onLoad: function (options) { wx.showShareMenu({ //只有擁有 shareTicket 才能拿到群信息,用戶每次轉發都會生成對應唯一的shareTicket 。 withShareTicket: true }); }, onShareAppMessage: function () { var that = this; console.log("onShareAppMessage") return { title: '穿越換裝', path: '/pages/avatarUpload/index/index', success: function (res) { if (res.errMsg == 'shareAppMessage:ok') { if (res.hasOwnProperty('shareTickets')) { console.log(res.shareTickets[0]); //分享到群 that.data.qunshare = 1; that.data.geshare = 1; } else { // 分享到個人 that.data.geshare = 1; } wx.showToast({ title: '分享成功', icon: 'success', duration: 500 }); console.log("shareAppMessage:ok"+ "qun"+ that.data.qunshare +"geren"+ that.data.geshare) } }, fail: function (res) { if (res.errMsg == 'shareAppMessage:fail cancel') { wx.showToast({ title: '分享失敗', icon: 'loading', duration: 500 }) } console.log("shareAppMessage:err") } } }, */
真機調試 return中內容無法進去;
--