我正在将我的应用程序从Angular 5迁移到角度6.除了延迟加载的模块外,一切正常。我在运行应用程序时遇到以下错误
虽然,我的应用程序运行良好,角度为5.我的所有js路径都是这样的
<script type="text/javascript" src="http://localhost:4200/dist/polyfills.js"></script>
<script type="text/javascript" src="http://localhost:4200/dist/scripts.js"></script>
<script type="text/javascript" src="http://localhost:4200/dist/styles.js"></script>
<script type="text/javascript" src="http://localhost:4200/dist/vendor.js"></script>
<script type="text/javascript" src="http://localhost:4200/dist/main.js"></script>
然后为什么从主域URL加载延迟加载的模块?喜欢localscorm?
我的package.json文件是
"scripts": {
"ng": "ng",
"start": "ng serve --deploy-url http://localhost:4300/dist/ --serve-path /dist/ --public-host http://localhost:4300",
"build": "ng build",
"build:prod": "ng build --prod --base-href ./",
"build:webprod": "ng build --prod --output-path ../dist --deploy-url ../dist/",
"build:webstaging": "ng build --env=staging --prod --output-path ../dist --deploy-url ../dist/",
"test": "ng test",
"lint": "ng lint",
"watch:tsc": "tsc -p src/tsconfig.app.system.json -w",
"html": "copyfiles -u 1 src/app/**/*.html src/app/**/*.css ../dist/",
"assets": "copyfiles -u 1 src/assets/**/* ../dist/",
"watch:global:static": "npm run assets",
"watch:app:static": "npm run html",
"watch": "npm-watch",
},
如何解决此加载块问题?
答案 0 :(得分:0)
答案 1 :(得分:0)
要解决Angular 6中的问题,请在angular.json
内添加以下配置
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "scorm-app:build:local",
"port": 4300,
"servePath": "/dist/",
"publicHost": "http://localhost:4300"
}
其中"browserTarget": "scorm-app:build:local"
指向本地环境的配置。