收藏
回答

onShareTimeline打印this是undefined?

场景:微信小程序安卓手机分享朋友圈,this.data.title 取不到值,直接报错。

  //分享朋友圈
  onShareTimeline() {
    console.log('分享朋友圈',this) // 分享朋友圈
    return {
      title: this.data.title // Cannot read property 'data' of undefined
    }
  }
回答关注问题邀请回答
收藏

2 个回答

  • Admin ²º²³
    Admin ²º²³
    2020-08-13
      onShareTimeline: function (res) {
        console.log('分享朋友圈',this) // 分享朋友圈
        return {
          title: this.data.title // Cannot read property 'data' of undefined
        }
      }
    
    2020-08-13
    有用
    回复 1
    • 孔鹏芳
      孔鹏芳
      2020-08-13
      还是undefined
      2020-08-13
      回复
  • 拾忆
    拾忆
    2020-08-13

    let _this =this;return { _this.data.title}

    2020-08-13
    有用
    回复 1
    • 孔鹏芳
      孔鹏芳
      2020-08-13
      还是undefined
      2020-08-13
      回复
登录 后发表内容
问题标签