angular - 导入两个同名的导出类

标签 angular typescript ionic2

在 typescript 中,使用 Angular 2,我需要导入两个具有相同名称但位于不同路径的类。

项目太大,导出的类名很难改。

有没有办法给导入的类起别名,

import {Class1} from '../location1/class1'
import {Class1} from '../location2/class1'

最佳答案

你可以像这样使用as:

import {Class1} from '../location1/class1'
import {Class1 as Alias} from '../location2/class1'

您可以找到有关 ES6 导入语句的更多信息 here .

关于angular - 导入两个同名的导出类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39610294/

相关文章:

javascript - 尝试覆盖和扩展 Typescript 子类中的方法签名

javascript - ionic2 - 滚动触发

regex - Angular 中没有空间验证器

angular - 无法重置包含选择的 react 形式

javascript - TypeScript - 如何定义具有任何类型参数的函数类型

angular - 添加组件 Input() with dot notation options : attr. src, style.padding.px

javascript - ionic 3 angular 4 http拦截器显示每个请求的加载

带有 Auth0 的 CouchDB

angular2 在特定元素上手动触发点击事件

angular - 在nebular开发的ngx-admin中将侧边栏更改为右侧