angular2中systemjs的问题
网上没搜寻到什么systemjs的资料
如下代码,
有几个问题:
1.
"materialize": "npm:angular2-materialize",
"angular2-materialize": "npm:angular2-materialize",
这两句什么意思?,后面的路径是一样的,前面的名字起什么作用?
2.
packages: {
app: {
main: './main.js',
// defaultExtension: 'js'
},
package是干嘛的,注释说是当没有文件名的时候告诉加载器如何加载?这句话怎么理解?
全部代码:
/**
* System configuration for Angular samples
* Adjust as necessary for your application needs.
*/
(function (global) {
System.config({
defaultJSExtensions: true,
paths: {
// paths serve as alias
'npm:': 'node_modules/'
},
// map tells the System loader where to look for things
map: {
// our app is within the app folder
app: 'app',
// angular bundles
'@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-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/forms': 'npm:@angular/forms/bundles/forms.umd.js',
// other libraries
'rxjs': 'npm:rxjs',
// 'angular-in-memory-web-api': 'npm:angular-in-memory-web-api',
'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
'angular2-cookie': 'npm:angular2-cookie',
//material
"materialize-css": "npm:materialize-css",
"materialize": "npm:angular2-materialize",
"angular2-materialize": "npm:angular2-materialize",
// 'ng2-image-lazy-load': 'node_modules/ng2-image-lazy-load'
'angular2-infinite-scroll': 'npm:angular2-infinite-scroll'
},
// packages tells the System loader how to load when no filename and/or no extension
packages: {
app: {
main: './main.js',
// defaultExtension: 'js'
},
rxjs: {
// defaultExtension: 'js'
},
'angular-in-memory-web-api': {
main: './index.js',
// defaultExtension: 'js'
},
"materialize-css": {
// "format": "global",
main: "dist/js/materialize",
// "defaultExtension": "js"
},
"materialize": {
main: "dist/materialize-directive",
// "defaultExtension": "js"
},
'angular2-cookie': {
main: './core.js',
// defaultExtension: 'js'
},
'angular2-infinite-scroll': {
main: './angular2-infinite-scroll.js',
// defaultExtension: 'js'
},
}
});
})(this);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SystemJS配置文件, 主要配置着需要由SystemJS加载的由Typescript编译器所编译的模块。
对于那些单独的JS文件,允许通过配置一个映射map和包入口(packages)来加载。
比如你需要加载模块 app/test , SystemJS会按下面的步骤来执行:
看有没有事先在systemJS中注册:System.register('app/test', ...)
如果没有,则就会去配置文件查找是否存在app映射(map), 是否有存在app packages 入口,如果找到了,则会建立请求来加载对应的模块: http://localhost:3000/app/tes...
如果你的app映射是map: { app: dist }
这个时候request 就会是 http://localhost:3000/dist/te...