我正在遵循《英雄之旅》教程,并且一切正常,除了一件事:导入自定义模块时,必须声明带有.js
扩展名的导入,否则得到404:
//This works fine
import {Component} from 'angular2/core';
//This gives me a 404 module not found (http://localhost:3000/assets/html/app/hero)
import {HeroDetailComponent } from './hero-detail.component';
//This works fine but the editor (VS Code) don't like it
import {HeroDetailComponent } from './hero-detail.component.js';
我想念什么吗?
感谢@JSess向我指出了正确的方向,我发现我的配置是错误的,因为该包下的属性实际上是模块的路径:
System.config({
packages: {
//THIS IS THE WRONG PATH
'app': {
format: 'register',
defaultExtension: 'js'
}
}
});
我只需要更改包下的属性即可反映模块的实际路径:
System.config({
packages: {
'assets/html/app': {
format: 'register',
defaultExtension: 'js'
}
}
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句