2

用uni-app构建的支付宝小程序,要用营销组件mkt

   <!-- #ifdef MP-ALIPAY -->
    <mkt
        mode="AUTOMATIC"
        boothCode="MERCHANT_SELF_TINYAPP"
        onError="onError" onRender="onRender" onApplySuccess="onApplySuccess"
    />
    <!-- #endif -->

直接在methods里面写onError,onRender,onApplySuccess方法将获取不到回调
解决办法
在onload里面写

  this.$scope.onRender = this.onRender.bind(this)
  this.$scope.onApplySuccess = this.onApplySuccess.bind(this)
  this.$scope.onError = this.onError.bind(this)
 methods: {
      onError (e) {
        console.log('mktError2',e)
      },
      onRender (e) {
        console.log('onRender2',e)

      },
      onApplySuccess (e) {
        console.log('onApplySuccess2',e)
      },
}

这样就能获取到回调了


流年朝朝
128 声望12 粉丝

但行好事,莫问前程