twa*_*ron 2 angular-cli angular
我们在 IIS 中运行我们的 angular 应用程序作为虚拟应用程序“myapplication”
在我们的 angular 应用程序中,我在 index.html 中设置了:
<base href="/myapplication/">
Run Code Online (Sandbox Code Playgroud)
它在 IIS 中运行良好。但是现在NG服务不起作用。因为它无法在http://localhost/myapplication/下找到所有包,因为 CLI 没有在该路径下运行。
我试过了
ng serve --base-href /myapplication/
Run Code Online (Sandbox Code Playgroud)
并浏览到http://localhost:4200/myapplication/
我仍然看到相同的错误。
我如何告诉 CLI 在“ http://localhost:4200/myapplication/ ”下为应用程序提供服务?
将基本 href 更改为:
<base href="/">
Run Code Online (Sandbox Code Playgroud)
这为开发时间设置了默认值。
然后,当您为生产构建时,请使用:
ng serve --base-href /myapplication/
Run Code Online (Sandbox Code Playgroud)
这将在构建用于部署的文件时正确设置。
归档时间: |
|
查看次数: |
2669 次 |
最近记录: |