【发布时间】:2020-02-15 14:52:45
【问题描述】:
所以我试图从支付应用程序razorpay 的api 的回调响应中调用一个函数。我不能使用“this”来调用组件内的函数,因为它位于处理程序的嵌套函数中。如何从回调“handler”中调用函数handle_response()?
myComponent.ts
var options = {
"amount": 100,
"name": "ABC",
"currency": "USD",
"handler": function (response){
console.log(response);//this returns the expected value
this.handle_response(response); //does not work as cannot identify 'this'
}
};
var rzp1 = new this.winRef.nativeWindow.Razorpay(options);
rzp1.open();
handle_response(_response){....}
【问题讨论】: