onShareTimeline打印this是undefined?
发布于 5 年前 作者 ming26 12689 次浏览 来自 官方Issues

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

  //分享朋友圈
  onShareTimeline() {
    console.log('分享朋友圈',this) // 分享朋友圈
    return {
      title: this.data.title // Cannot read property 'data' of undefined
    }
  }
3 回复
  onShareTimeline: function (res) {
    console.log('分享朋友圈',this) // 分享朋友圈
    return {
      title: this.data.title // Cannot read property 'data' of undefined
    }
  }

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

回到顶部