微信小程序--分享報錯(thirdScriptError Cannot read property 'from' of undefined;at pages/index/index page onShareAppMessage function TypeError: Cannot read property 'from' of undefined)


分享功能:

 

onShareAppMessage: function (res) {
if (res.from === 'button') {
// 來自頁面內轉發按鈕
console.log(res.target)
}
return {
title: '首頁',
path: 'pages/index/index',
imageUrl: "../../img/share.png"
}
}

 

今天在開發小程序分享功能時,報錯如下。

thirdScriptError
Cannot read property 'from' of undefined;at pages/index/index page onShareAppMessage function
TypeError: Cannot read property 'from' of undefined

 

后來查看微信開發社區發現:

10月10日起新提交發布的版本,不再支持分享回調參數 success 、fail 、complete,即用戶從小程序/小游戲中分享消息給好友時,開發者將無法獲知用戶是否分享完成,也無法在分享后立即獲得分享成功后的回調參數shareTicket。該調整可以在基礎庫 2.3.0及以上版本體驗。

 

由於不再支持分享回調參數,所以報錯。報如下代碼刪除即可

if (res.from === 'button') {
// 來自頁面內轉發按鈕
console.log(res.target)
}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM