【发布时间】:2019-11-24 17:30:03
【问题描述】:
在方法中运行时,无法在构造函数中分配只读属性,
打字稿版本是 3.4.1
class Example {
readonly initialState: any
constructor(){
this.someMethod()
}
private someMethod(){
this.initialState = 'someState'
}
}
【问题讨论】:
-
在构造函数中只能分配只读字段。
标签: typescript