0
爲什麼試圖聲明一個常量,當我得到錯誤:常量上Angular2以打字稿
Expecting new line or semicolon
export class MyClass{
const ALLOC_INVESTORS = "Allocation Investors";
}
爲什麼試圖聲明一個常量,當我得到錯誤:常量上Angular2以打字稿
Expecting new line or semicolon
export class MyClass{
const ALLOC_INVESTORS = "Allocation Investors";
}
的情況下,有人需要。 而不是const,只能使用readonly。
readonly ALLOC_INVESTORS:string = "Allocation Investors";
如果[嘗試在操場上(http://www.typescriptlang.org/play/index.html#src=export%20class%20MyClass%7B%0A%0A%20%20% 20%20const%20ALLOC_INVESTORS%20%3D%20%22Allocation%20Investors%22%3B%0A%0A%7D)它會告訴你'const'不能用在類聲明中。 –
@MikeMcCaughan打字稿類中的const可以替代什麼? – commonSenseCode
http://stackoverflow.com/q/37265275/215552 :) –