zoukankan      html  css  js  c++  java
  • 微信小程序--分享报错(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)
    }
  • 相关阅读:
    2.MYSQL之初体验
    nginx+uWSGI+django+virtualenv+supervisor
    静态动态网页
    web server 基础知识
    nginx与location语法详解
    编译安装nginx
    虚拟环境之virtualenvwrapper
    python开发之virtualenv
    【剑指Offer】面试题12. 矩阵中的路径
    【剑指Offer】面试题11. 旋转数组的最小数字
  • 原文地址:https://www.cnblogs.com/Super-scarlett/p/9712124.html
Copyright © 2011-2022 走看看