我尝试组件相对模板URLS,如下所示
dialog.component.ts
@Component({
moduleId: module.id,
selector: 'modal-confirm',
templateUrl: 'dialog.component.html',
styleUrls: ['dialog.component.css']
})tsconfig.json
"compilerOptions": {
"target": "es5",
"module": "commonjs",
....
},systemjs.config.js
typescriptOptions: {
emitDecoratorMetadata: true,
experimentalDecorators: true,
module: "commonjs",
},使用JiT,我得到
Error: (SystemJS) module is not defined
ReferenceError: module is not defined at eval (http://localhost:3000/app/shared/services/dialog.component.ts!transpiled:104:35)点击链接,它就会转到这一行。
moduleId: module.id,我错过了什么?
UPDATE实际上收到的错误比上面提到的更多。在许多情况下,AoT需要更严格的代码才能通过类型检查器。这比我预期的要复杂得多。在JiT模式下工作的东西可能不能在AoT模式下工作。我会再等3-6个月,看看AoT编译器是如何改进的。
发布于 2016-11-22 15:45:09
是。
如果使用的是dist文件夹,请确保将所有所需文件(如.css, .js )复制到与默认目录结构相同的dist文件夹(与运行gulp/grunt任务之前相同的目录结构)。
发布于 2017-09-12 05:57:04
这是解决办法
For systemjs, here I should use __moduleName instead of module.idhttps://stackoverflow.com/questions/40733108
复制相似问题