部署后未定义参考错误-webpackJsonp

时间:2019-07-11 06:40:02

标签: angular npm

使用Angular 4应用程序,在开发模式下运行示例时,在大多数情况下,面对webpackJsonp部署后,它工作良好。

这是我创建的包:index.html文件

enter image description here

这是我的包json

  

{ "name": "my-request", "version": "0.0.0", "license": "MIT", "scripts": { "ng":"ng", "start":"ng serve", "build":"ng build", "test":"ng test", "lint":"ng lint", "e2e":"ng e2e" }, "private": true, "dependencies": { "@angular/animations": "^5.0.0", "@angular/common": "^5.0.0", "@angular/compiler": "^5.0.0", "@angular/core": "^5.0.0", "@angular/forms": "^5.0.0", "@angular/http": "^5.0.0", "@angular/platform-browser": "^5.0.0", "@angular/platform-browser-dynamic": "^5.0.0", "@angular/router": "^5.0.0", "classlist.js": "^1.1.20150312", "core-js": "^2.4.1", "file-saver": "^1.3.8", "ngx-cookie-service": "^1.0.10", "ngx-pagination": "^3.1.1", "rxjs": "^5.5.12", "web-animation-js": "^2.3.1", "xlsx": "^0.13.1", "zone.js": "^0.8.14" }, "devDependencies": { "@angular/cli": "1.6.6", "@angular/compiler-cli": "^5.0.0", "@angular/language-service": "^5.0.0", "@types/jasmine": "~2.5.53", "@types/jasminewd2": "~2.0.2", "@types/node": "~6.0.60", "codelyzer": "~4.0.1", "jasmine-core": "~2.6.2", "jasmine-spec-reporter": "~4.1.0", "karma": "~1.7.0", "karma-chrome-launcher": "~2.1.1", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^1.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.1.2", "ts-node": "~3.2.0", "tslint": "~5.7.0", "typescript": "~3.5.2" } }

1 个答案:

答案 0 :(得分:0)

尝试验证这些脚本的来源,在开发过程中链接可以正常工作,但是在您构建项目结构时稍作更改,最好的方法是将所有脚本,css和图像资源放置在资产文件夹中并更改您的源url从资产文件夹中获取文件。

<script src="assets/vendor.bundle.js"></script>