我不太了解systemjs我在尝试通过angular
导入时遇到问题效果很好
Import {UtilClass} from './shared/util.class';
我在另一个文件夹中有一个组件但是如果我尝试加载它
Import {UtilClass} from '../shared/util.class';
我有以下错误并在日志加载文件中验证我观察到的是当我使用" ../" 时它没有放置扩展名js / util.class 404(未找到)
(function (global) {
var staticPath='src/';
var paths = {
// paths serve as alias
'npm:': 'https://unpkg.com/'
};
// map tells the System loader where to look for things
var map = {
'app': 'app',
// angular bundles
'@angular/animations': 'npm:@angular/animations/bundles/animations.umd.js',
'@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
'@angular/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js',
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
'@angular/router/upgrade': 'npm:@angular/router/bundles/router-upgrade.umd.js',
'@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
'@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js',
'@angular/upgrade/static': 'npm:@angular/upgrade/bundles/upgrade-static.umd.js',
// other libraries
'rxjs': 'npm:rxjs@5.0.1',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'ts': 'npm:plugin-typescript@5.2.7/lib/plugin.js',
'typescript': 'npm:typescript@2.2.1/lib/typescript.js',
};
// packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app': {
main: '../..' + staticPath + '/main',
defaultExtension: 'js',
defaultJSExtensions: true
}
,
'rxjs': {
defaultExtension: 'js'
}
};
var config = {
map: map,
packages: packages,
paths: paths
};
System.config(config);
})(this);
答案 0 :(得分:0)
当路线相对时会发生此错误,我想有更好的方法可以纠正它。
var packages = {
'app': {
main: '../..' + staticPath + '/main',
defaultExtension: 'js',
defaultJSExtensions: true
}
,
'rxjs': {
defaultExtension: 'js'
}
};
//I added this and works
packages['./../..'+staticPath+'/']={main:'main',defaultExtension: 'js'}