1

我正在研究 Angular Ahead of Time Compilation(AoT),在那里我生成了 build.js 文件,并且在加载时遇到了以下问题

(SystemJS) XHR error (404 Not Found) loading http://localhost:58082/aot/app/app.module.ngfactory

包含在 index.html 中的以下文件

<script src="shim.min.js"></script>
    <script src="zone.min.js"></script>
4

1 回答 1

0

得到这个问题的三种可能性

1) 我们在 index.html 页面中包含这个脚本

 <script>window.module = 'aot';</script>

所以我们必须在每个组件中包含模块字段以及选择器和模板

@Component({
    moduleId: module.id,
    selector: 'myapp',
    templateUrl: '../../master/html/test.html'
})

2)这个脚本应该在html页面的底部

<script src="dist/build.js"></script>

3)最后但重要的是,提前编译没有延迟加载

这解决了我的问题,使用 AOT 的应用程序正在运行,但内部遇到了一些问题,例如堆栈未定义的 Zoneware 错误。正在解决它们。

于 2017-01-20T13:35:37.460 回答