我的项目运行完美,但是当我实现通用时,我得到“窗口未定义”。
我的错误如下。
node_modules/hammerjs/hammer.js:2643
})(window, document, 'Hammer');
^
ReferenceError: window is not defined
at Object.<anonymous> (/var/www/html/resumeble_unv/node_modules/hammerjs /hammer.js:2643:4)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at node_modules/ngx-carousel/bundles /ngxcarousel.umd.js:2:174
at Object.<anonymous> (node_modules/ngx-carousel/bundles/ngxcarousel.umd.js:5:2)
Run Code Online (Sandbox Code Playgroud)
包.json
{
"name": "resumable-ang",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"prestart": "ng build --prod && ngc",
"start": "ts-node src/server.ts" },
"private": true,
"dependencies": {
"@angular/animations": "^4.4.6",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": …
Run Code Online (Sandbox Code Playgroud) 在下面的代码中,我得到的Cannot read property 'http' of undefined
是未定义的。如何在 onAuthorize 函数中调用外部自定义函数。
这是我获得帮助的链接https://developer.paypal.com/demo/checkout/#/pattern/client 您的任何帮助都将是可观的。
ngAfterViewInit(): void {
const total = this.total_amount;
const selected_package = this.selected_package.name;
this.loadExternalScript('https://www.paypalobjects.com/api/checkout.js').then(() => {
paypal.Button.render({
env: 'sandbox',
client: {
production: '',
sandbox: 'XXXXXXXXXXXXXXXXXXXXXXX'
},
commit: true,
payment: function (data, actions) {
return actions.payment.create({
payment: {
transactions: [
{
amount: { total: total, currency: 'USD' },
description: selected_package,
}
]
}
})
},
onAuthorize: function (data, actions) {
return actions.payment.execute().then(function (payment) {
const formdata: FormData = new FormData; …
Run Code Online (Sandbox Code Playgroud)