angular2 – 什么是所有index.ts用于?

前端之家收集整理的这篇文章主要介绍了angular2 – 什么是所有index.ts用于?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我一直在看几个种子项目,所有的组件似乎有一个index.ts从该组件输出*。我不能在任何地方找到它实际使用的是什么?

例如https://github.com/mgechev/angular2-seed/tree/master/src/client/app/%2Bhome

谢谢

https://angular.io/docs/ts/latest/guide/glossary.html

A barrel is a way to rollup exports from several modules into a single
convenience module. The barrel itself is a module file that re-exports
selected exports of other modules.

Imagine three modules in a heroes folder:

06000

Without a barrel,a consumer would need three import statements:

06001

We can add a barrel to the heroes folder (called index by convention)
that exports all of these items:

06002

Now a consumer can import what it needs from the barrel.

06003

The Angular scoped packages each have a barrel named index.

参见Angular 2 DI Error – EXCEPTION: Can’t resolve all parameters

原文链接:https://www.f2er.com/angularjs/145861.html

猜你在找的Angularjs相关文章