我正在尝试按照 angular guide 的“可能的最简单部署”部分中指定的方式部署我的应用程序。 我已经通过快速启动设置创建了该项目。为了部署应用程序,我更改了以下文件: index.html、main.ts、systemjs.config.server.js,路径为 https://unpkg.com/ 但我收到 html 模板的 404 错误。例如:
GET http://localhost:3001/app.component.html 404(未找到)zone.js:2616
当我恢复到默认设置时,我的应用程序运行良好。
具体来说,systemjs.config 中的以下部分:
paths: {
// paths serve as alias
'npm:': 'node_modules/'
}
app.component.ts
import { Component } from '@angular/core';
@Component({
selector: 'app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent {}
在这两种情况下,我都通过 npm start
提供服务。
最佳答案
我认为这是 Angular4 中的一个错误,我有时也遇到这个错误。 通过在 main.ts 中添加以下内容来解决: 导入 'zone.js/dist/zone';
关于javascript - Angular 4,如何修复 "simple deployment"中 html 文件的 404 错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45216485/