我从许多文件中导入很多模块。 有没有办法将所有导入文件放在单独的文件中? 我正在使用模块类型:es2015示例:
import {...} from '....1'; import {...} from '....2'; import {...} from '....'; import {...} from '....300';然后我将这个文件导入到需要导入模块的文件中,如下所示:
import * as IMPORTS from '...'不用说这些参考资料没有被发现。
我也尝试了这个stackoverlow线程中的建议方式, 但没有运气。
以下是我迄今为止所做的:
在一个单独的文件中有所有的导入文件。 在另一个文件中有/// <reference path='path to file above' />和从'上面'导出*。 在我想要使用所有这些导入的文件中,从'来自步骤2的文件'具有import * as ...。我在我试图导入的任何模块上都找不到错误。
I'm importing many modules from many files. Is there a way to have all the import files in a separate file? I'm using module type: es2015 example:
import {...} from '....1'; import {...} from '....2'; import {...} from '....'; import {...} from '....300';I then import this file in the file that I need the imported modules like so:
import * as IMPORTS from '...'Needless to say the references are not being found.
I also have tried the suggested way in this stackoverlow thread with no luck.
Here's what I did so far:
In a separate file have all the import files. In another file have ///<reference path='path to file above' /> and export * from 'above'. In the file I want to use all those imports, have import * as ... from 'file from step 2'.I get a not found error on any of those modules that I try to import.
最满意答案
我最终用出口替换了第1步中创建的文件中的所有导入 。 这样就不需要额外的中间文件(步骤2)。 尽管我现在从第一个文件导入,但第三步从顶部开始是一样的。
I ended up replacing all imports in the file created in step 1 with exports. This way there is no need for an extra intermediary file (step 2). Step three from the top is the same though I'm importing from the first file now.
更多推荐
发布评论