Angular 2+ 拥有主导入文件
Angular 2+ having a master import file
我有包含如下数据的差异文件:
export const config1 = { stuff here }
export const config2 = { other stuff here }
export const config3 = { other stuff here }
然后我导入它们:
import { config1 } from 'some path';
import { config2 } from 'some path';
import { config2 } from 'some path';
我要做的是拥有一个包含所有导入的索引文件,所以我只导入 1 个?
所以我只需要做
而不是上面的
import { whatever } from 'path'
然后我这样使用它:
whatever.config1....
我该怎么做?
创建文件,例如configs.ts
并从中导出:
export * from 'some path for config1';
export * from 'some path for config2';
export * from 'some path for config3';
然后你可以从这个文件导入:
import { config1, config2, config3, whatever_else } from './path/to/configs';
我有包含如下数据的差异文件:
export const config1 = { stuff here }
export const config2 = { other stuff here }
export const config3 = { other stuff here }
然后我导入它们:
import { config1 } from 'some path';
import { config2 } from 'some path';
import { config2 } from 'some path';
我要做的是拥有一个包含所有导入的索引文件,所以我只导入 1 个?
所以我只需要做
而不是上面的import { whatever } from 'path'
然后我这样使用它:
whatever.config1....
我该怎么做?
创建文件,例如configs.ts
并从中导出:
export * from 'some path for config1';
export * from 'some path for config2';
export * from 'some path for config3';
然后你可以从这个文件导入:
import { config1, config2, config3, whatever_else } from './path/to/configs';