[英]SystemJS Angular2 boot loader not found
When I try to import the boot.js from a layout page, I keep getting a 404 error. 当我尝试从布局页面导入boot.js时,始终出现404错误。
Here is the code I am using to import it: 这是我用来导入它的代码:
<!-- Configure SystemJS -->
<script src="/appScripts/config.js"></script>
<script>
System.import('/appScripts/boot')
.then(null, console.error.bind(console));
</script>
Here is my folder structure: 这是我的文件夹结构:
Everything works fine when I use index.html (seen in wwwroot), but not when I try from /views/shared/_layout.cshtml 当我使用index.html(在wwwroot中看到)时,一切正常,但从/views/shared/_layout.cshtml尝试时,一切都没有
Here is my config.js 这是我的config.js
(function (global) {
// map tells the System loader where to look for things
var map = {
'app': 'appScripts', // 'dist',
'rxjs': 'libs/rxjs',
'angular2-in-memory-web-api': 'libs/angular2-in-memory-web-api',
'@angular': 'libs/@angular'
};
// packages tells the System loader how to load when no filename and/or no extension
var packages = {
'app': { main: 'boot.js', defaultExtension: 'js' },
'rxjs': { defaultExtension: 'js' },
'angular2-in-memory-web-api': { defaultExtension: 'js' },
};
var packageNames = [
'@angular/common',
'@angular/compiler',
'@angular/core',
'@angular/http',
'@angular/platform-browser',
'@angular/platform-browser-dynamic',
'@angular/router',
'@angular/router-deprecated',
'@angular/testing',
'@angular/upgrade',
];
// add package entries for angular packages in the form '@angular/common': { main: 'index.js', defaultExtension: 'js' }
packageNames.forEach(function (pkgName) {
packages[pkgName] = { main: 'index.js', defaultExtension: 'js' };
});
var config = {
map: map,
packages: packages
}
// filterSystemConfig - index.html's chance to modify config before we register it.
if (global.filterSystemConfig) { global.filterSystemConfig(config); }
System.config(config);
})(this);
Thank you very much for your help and please let me know if you need more information. 非常感谢您的帮助,如果您需要更多信息,请告诉我。
I thought I had tried this, but it is hard to keep track of it all. 我以为我已经尝试过了,但是很难跟踪到这一切。 Here is how I solved this.
这是我解决此问题的方法。 Notice the baseURL line.
注意baseURL行。
<!-- Configure SystemJS -->
<script>System.config({ baseURL: '/' });</script>
<script src="/appScripts/config.js"></script>
<script>
System.import('appScripts/boot').catch(console.log.bind(console));
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.