使用VS代码angular 14
项目从angular 8 更新
ng build和ng serve运行良好。
但是http://localhost:4200/给出以下错误:未能加载资源:服务器的响应状态为404(未找到(:4200//assets/config.json:1
我一直呆在这里。
在此处输入图像描述
在此处输入图像描述
在文件configuration.service.ts
中有这个
private get configurationUrl(): string {
const path = (environment.configurationPath.startsWith('/') ? '' : '/') + environment.configurationPath; const baseUrl = this.window.document.baseURI; return ${baseUrl}${path};
}
我更改了第一行,因为它添加了一个反斜杠,我不知道是什么原因。
private get configurationUrl(): string {
const path = environment.configurationPath; const baseUrl = this.window.document.baseURI; return ${baseUrl}${path};
}
这就解决了问题。所以感谢大家的帮助,这让我想到了寻找这个双反斜杠