码迷,mamicode.com
首页 > 其他好文 > 详细

[TS] Class Properties Public, Private and Read Only Modifiers

时间:2018-02-05 21:58:02      阅读:186      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!