用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)
},
}
這樣就能獲取到回撥了