导入两个具有相同名称的导出类
问题描述:
在打字稿中,使用Angular 2,我需要导入两个具有相同名称但位于不同路径的类.
In typescript, using Angular 2, I need to import two classes with the same name, but lying in different paths.
该项目太大,以至于我很难更改导出的类名.
The project is quite too big that I find it hard to change the exported class names.
有什么办法别名导入的类吗?
Is there any way to alias the imported classes,
import {Class1} from '../location1/class1'
import {Class1} from '../location2/class1'
答
您可以像这样使用as
:
import {Class1} from '../location1/class1'
import {Class1 as Alias} from '../location2/class1'
您可以在此处找到更多有关ES6导入语句的信息. .