Angular NG使用VirtualPath或子目录提供服务

Angular NG使用VirtualPath或子目录提供服务,angular,angular-cli,Angular,Angular Cli,我们在IIS中将angular应用程序作为虚拟应用程序“myapplication”运行 在我们的angular应用程序中,我在index.html中设置了: <base href="/myapplication/"> 并浏览至 我仍然看到同样的错误 如何告诉CLI在“”下为应用程序提供服务?将基本href更改为: <base href="/"> 这将在它生成用于部署的文件时正确设置它。如果要区分用于路由和资产的基本路径,可以同时使用--base href和--de

我们在IIS中将angular应用程序作为虚拟应用程序“myapplication”运行

在我们的angular应用程序中,我在index.html中设置了:

<base href="/myapplication/"> 
并浏览至

我仍然看到同样的错误


如何告诉CLI在“”下为应用程序提供服务?

将基本href更改为:

<base href="/">

这将在它生成用于部署的文件时正确设置它。

如果要区分用于路由和资产的基本路径,可以同时使用
--base href
--deploy url

ng serve --base-href /myapplication --deploy-url /static
您的应用程序现在应该可以在http://localhost:4200/myapplication 而您的静态文件将从http://localhost:4200/static.

您还可以在
workspace.json
config文件中添加这些


大部分时间
baseHref
应该足够了。

ahhh我倒过来理解它!谢谢黛博拉!
ng serve --base-href /myapplication/
ng serve --base-href /myapplication --deploy-url /static