使用 MVC5 应用程序延迟加载 Angular 模块时出错 [英] Error while Lazy Loading Angular Modules With MVC5 Application

查看:21
本文介绍了使用 MVC5 应用程序延迟加载 Angular 模块时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Angular 5 构建 MVC5 应用程序,我正在使用 Angular Cli 创建 Angular 应用程序.

I am building MVC5 application with Angular 5 and I am using Angular Cli to create angular app.

问题是应用程序在端口 7076 上运行,而 angular 应用程序使用 angular cli 使用端口 4200.当我运行 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆