【问题标题】:const on Angular2 with TypescriptAngular 2 中的 const 和 Typescript
【发布时间】:2017-01-22 16:38:36
【问题描述】:

为什么在尝试声明 const 时出现错误:

Expecting new line or semicolon

export class MyClass{

    const ALLOC_INVESTORS = "Allocation Investors";

}

【问题讨论】:

标签: angular typescript


【解决方案1】:

以防万一。 使用只读而不是 const。

readonly ALLOC_INVESTORS:string = "Allocation Investors";

【讨论】:

    猜你喜欢
    • 2016-08-05
    • 2021-07-24
    • 2017-09-16
    • 2016-07-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多