用 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)
},
}
这样就能获取到回调了