简体   繁体   English

这些angular2导入的目的是什么?

[英]what is the purpose of these angular2 imports?

I am a newbie in angular2 and want to know the purpose of following imports we do in our angular2 app. 我是angular2的新手,想知道我们在angular2应用程序中进行导入的目的。

<script src="node_modules/es6-shim/es6-shim.min.js"></script>
<script src="node_modules/systemjs/dist/system-polyfills.js"></script>
<script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
<script src="node_modules/systemjs/dist/system.src.js"></script>
<script src="node_modules/rxjs/bundles/Rx.js"></script>
<script src="node_modules/angular2/bundles/angular2.dev.js"></script>
<script src="node_modules/angular2/bundles/http.dev.js"></script>

so my questions regarding these imports are: 所以我对这些进口商品的疑问是:

  • what are these imports for? 这些进口是做什么用的?
  • does the sequence of these imports metter? 这些进口量表的顺序是什么?
  • are there any other useful imports that we must be aware of? 我们还必须知道其他有用的进口吗?

Thanks in advance. 提前致谢。

I don't see any imports in your code sample. 在您的代码示例中没有看到任何导入 Its just including the files of various libraries into web page. 它只是将各种库的文件包含到网页中。 If you read some of them one by one: 如果您逐一阅读其中的一些内容:

  • es6-shim.min.js - adds ES6 language features to browsers ( full list ) es6-shim.min.js-向浏览器添加ES6语言功能( 完整列表
  • Rx.js adds Observables library ( GitHub RxJS ) Rx.js添加了Observables库( GitHub RxJS
  • http.dev.js - adds angular2 $http module to make requests http.dev.js-添加angular2 $ http模块以发出请求

So you can google each of the names and figure out for yourself if that's applicable for your project. 因此,您可以搜索每个名称,然后自己确定是否适用于您的项目。

More on modules and actual imports in ES2015/ES6 you can read here https://ponyfoo.com/articles/es6-modules-in-depth for example. 有关ES2015 / ES6中模块和实际imports更多信息,例如,您可以在此处阅读https://ponyfoo.com/articles/es6-modules-in-depth

"useful imports that we must be aware of?" “我们必须意识到有用的进口?”

Totally depends on your needs. 完全取决于您的需求。 By I assume angular2.dev.js and http.dev.js would be a good to start. 我认为angular2.dev.js和http.dev.js是一个很好的开始。

"does the sequence of these imports matter?" “这些进口的顺序重要吗?”

Not now, but only if you're using proper module system so that browser can load missing parts before executing the blocks that depend on them. 不是现在,但是只有当您使用适当的模块系统时,浏览器才能在执行依赖于它们的块之前加载缺少的部分。 And also the loader file (system.js/require.js) should be in the first before all the other files. 加载程序文件(system.js / require.js)也应位于所有其他文件之前的第一个。

Here are the details about what you specified in your script elements: 以下是有关您在脚本元素中指定的内容的详细信息:

  • The two first files aren't necessary if you use TypeScript and have configuted ES5 output. 如果使用TypeScript并配置了ES5输出,则不需要前两个文件。
  • angular2-polyfills.js - Contains ZoneJS (to trigger change detection - see What is the Angular2 equivalent to an AngularJS $watch? ) and reflect-metadata (to set metadata on objects from decorators) angular2-polyfills.js-包含ZoneJS(触发更改检测-请参阅Angular2等效于AngularJS $ watch? )和反射元数据(设置装饰器上对象的元数据)
  • system.src.js - SystemJS, the library that manages modules. system.src.js -SystemJS,用于管理模块的库。 In short when you use import and export in TypeScript the corresponding compiled code relies on it. 简而言之,当您在TypeScript中使用import和export时,相应的编译代码就依赖于它。
  • Rx.js - RxJS, a library that provides an implementation of Reactive Programming concepts. Rx.js -RxJS,一个提供响应式编程概念实现的库。 In short, it provides an implementArion of observables and their operators. 简而言之,它提供了可观察变量及其运算符的ImplementArion。 EventEmitters, HTTP rely on this. EventEmitters,HTTP依赖于此。
  • angular2.dev.js - Angular2 core bundle angular2.dev.js -Angular2核心包
  • http.dev.js - HTTP support of Angular2 http.dev.js - Angular2的 HTTP支持

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM