我正在尝试实现此链接中描述的导入桶结构(您可能需要向下滚动一点):
https://angular.io/docs/ts/latest/guide/style-guide.html#!#application-structure
我面临的问题是我正在创建和引用的 index.ts 文件像
import {...} from './shared/services';
在运行时未找到并抛出 404。如果我引用像
这样的模块import {...} from './shared/services/index';
它工作正常。问题只出现在运行时,typescript 不会报错并编译成功。我在 plunker 中复制了这个问题:
https://plnkr.co/edit/ClE76zuihFTETLDGehnd?p=preview
您可以在控制台中看到错误。
预先感谢您的帮助!
最佳答案
我终于找到了一些东西:https://www.reddit.com/r/Angular2/comments/4i2d9x/support_problem_with_barrels/
看来,这对于 SystemJS
来说并不容易,因为它无法处理桶文件。
要解决这个问题,您可以像使用 [...]/index
那样添加每个文件,或者您可以将它们作为一个包添加到 SystemJS
中
关于import - Angular2 - 导入桶在运行时导致 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37184073/