Angular 在 IIS-6 中部署时加载错误的资源路径

Angular loading wrong resources path when deploying in IIS-6

我运行以下命令

ng build --base-href /extDataAngular/

并将Dist文件夹中的所有文件放到IIS-6服务器

当我尝试在浏览器中打开 Url 时

它只是显示以下错误:

Not allowed to load local resource: file:///C:/Program%20Files/Git/extDataAngular/runtime.js
Not allowed to load local resource: file:///C:/Program%20Files/Git/extDataAngular/polyfills.js
Not allowed to load local resource: file:///C:/Program%20Files/Git/extDataAngular/styles.js
Not allowed to load local resource: file:///C:/Program%20Files/Git/extDataAngular/scripts.js
Not allowed to load local resource: file:///C:/Program%20Files/Git/extDataAngular/vendor.js
Not allowed to load local resource: file:///C:/Program%20Files/Git/extDataAngular/main.js
Not allowed to load local resource: file:///C:/Program%20Files/Git/assets/img/icon_logo.ico

有没有办法修复指向正确路径的资源路径?

正确的路径应该是://d:/app/extDataAngular

当前错误路径://C:/Program%20Files/Git/extDataAngular/vendor.js

如果您 运行 从项目的根文件夹中打开终端,请尝试 运行ning 'ng build --prod' 以确保您在构建中获得正确的文件。

此外,在 IIS 中确保网站的物理路径指向 d:/app/extDataAngular 文件夹,其中包含该网站 'Basic Settings' 中的构建。

可能值得考虑将您的 IIS 安装更新到 IIS 10(如果可能的话)。

希望对您有所帮助!

我找到了原因...这是因为 --href 这个用于 ng 构建的标签对我不起作用 构建文件后,我必须在 index.html

中提醒