使用MVC5应用程序延迟加载Angular模块时出错 [英] Error while Lazy Loading Angular Modules With MVC5 Application
问题描述
我正在使用Angular 5构建MVC5应用程序,并且正在使用Angular Cli创建角度应用程序.
I am building MVC5 application with Angular 5 and I am using Angular Cli to create angular app.
问题是应用程序在端口7076上运行,而角度应用程序在4200端口上使用angular cli运行.当我运行MVC应用程序时,除了延迟加载的模块之外,其他所有功能都正常运行.对于所有* .chunk.js文件,浏览器都直接在应用程序根目录中查找这些文件,而这些文件位于/dist/目录下.
The problem is that the application is running on port 7076 while angular app using angular cli using a port 4200. When I run the MVC application everything work fine except lazy loaded module. For all *.chunk.js files the browser looks those file directly in the application root directory, whereas these files are under /dist/ directory.
如何使* .chunk.js文件从dist文件夹加载?
How can we make the *.chunk.js files be loaded from dist folder?
推荐答案
我已经阅读了上面的内容,意识到这是一个古老的问题,但尚未解决,因此尝试给出有助于解决类似问题的人的答案.
I've read the above, realize this is an old question, but it's unresolved so trying to give an answer that helps who is facing similar issue.
>
要从"dist"文件夹中读取延迟加载的块文件,您需要从angular.json(Angular CLI)文件中设置"deployUrl"属性.
To read lazy loading chunk files from 'dist' folder you need to set 'deployUrl' property from angular.json (Angular CLI) file.
"deployUrl" : "dist/",
请确保dist文件夹路径或url的末尾有"/".
Please make sure "/" should be there at end of dist folder path or url.
这篇关于使用MVC5应用程序延迟加载Angular模块时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!