簡體   English   中英

是否有某些文件我不應該包含在Angular 2的桶文件中和/或導入順序是否重要?

[英]Are there certain files I should not be including in a barrel file in Angular 2 and/or does the order of imports matter?

我有一個index.ts的功能文件夾,如下所示:

export * from './grouping.model'
export * from './grouping.routing';
export * from './group.component';
export * from './supergroup.component';
export * from './grouping-container.component';
export * from './grouping.service';
export * from './grouping.module';

最初我收到此錯誤: Can't resolve all parameters for SupergroupComponent: (?, ActivatedRoute) 然后我改變了導出這些文件的順序,並得到了一個不同的問題( Unexpected value 'undefined' imported by the module 'GroupingModule' )。

如果我從這個桶文件中刪除.service文件並將其導入我的組件中的單獨一行,一切正常。 我似乎無法找到任何涉及此問題的內容,應該或不應該包含在桶文件中的內容,或者這些文件的導出順序是否重要。

我會假設訂單確實很重要,但我已經訂購了我的導入,以便我導入最低級別的構建塊並向上移動,但我仍然得到unresolved parameters錯誤。

原來是一個非常簡單的修復。 桶文件中的導出順序很重要。 從最低級別開始,按照自己的方式工作,這將解決問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM