【问题标题】:Partial classes in typescript打字稿中的部分类
【发布时间】:2017-05-11 09:42:52
【问题描述】:

文件.ts

export class ServiceUrls {
 static baseUrl: string = 'http://localhost:52949/V1/';
    static baseImageUrl: string = 'http://localhost:52949/';
}

files1.ts

extends interface  ServiceUrls{
 static baseUrl: string = 'http://localhost:52949/V1/';
    static baseImageUrl: string = 'http://localhost:52949/';
}

如何在 typescript 中实现部分类。我应该如何引用同一个类以使其像部分类一样工作。如果我在 files1.ts 中给出相同的类名,它会给出错误声明或预期的声明。

【问题讨论】:

标签: typescript partial-classes


【解决方案1】:

我创建并使用 @partial 装饰器充当简化语法,有助于将单个类的功能划分为多个类文件...https://github.com/mustafah/partials

【讨论】:

    猜你喜欢
    • 2020-12-20
    • 2020-04-06
    • 1970-01-01
    • 2018-12-21
    • 2020-06-25
    • 1970-01-01
    • 2020-04-13
    • 2021-12-23
    • 1970-01-01
    相关资源
    最近更新 更多