In the constructor, we want to set the prop to readonly, you need to do like this:
class Superhero { readonly name: string constructor( name: string, editor: string, createdYear: number ) { name = this.name; } }
标签:his wan blog tor class struct you public mod
In the constructor, we want to set the prop to readonly, you need to do like this:
class Superhero { readonly name: string constructor( name: string, editor: string, createdYear: number ) { name = this.name; } }
[TS] Class Properties Public, Private and Read Only Modifiers
标签:his wan blog tor class struct you public mod
原文地址:https://www.cnblogs.com/Answer1215/p/8419135.html