我正在使用 Angular 4 项目,我必须将 razorpay 集成到项目中,它在测试、开发环境中运行良好,但在特定环境中会引发错误,在实时环境中会引发以下错误。
vendor.cdeb9a8730a2fc78a675.bundle.js:1 错误类型错误:this.winRef.nativeWindow.Razorpay 不是构造函数
代码
rzp1:any;
this.rzp1 = new this.winRef.nativeWindow.Razorpay(this.paymentOptions, successCallback, cancelCallback);
this.rzp1.open(this.paymentOptions, successCallback, cancelCallback);
窗口参考服务
import { Injectable } from '@angular/core';
function _window() : any {
// return the global native browser window object
return window;
}
@Injectable()
export class WindowRefService {
get nativeWindow() : any {
return _window();
}
}