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

TypeScript专题-Static和使用技巧

时间:2019-04-09 22:10:15      阅读:154      评论:0      收藏:0      [点我收藏+]

标签:people   int   div   turn   创建   highlight   struct   class   创建类型   

class People {
	static _name: string; 
	print() {
		//alert(this.name);// 编译不通过,doex not exist on type People;声明为static的变量通过类名调用
        return(People._name)
	} 
    constructor(name){
        People._name = name;
    }
}
// let h = new People(); 
// // h.name = "aaa";
// People._name = "aaaa";
// h.print();
//创建类型,为当前类的类型(引用数据类型)
let p:People;
p = new People("aa");
alert(p.print())

  

TypeScript专题-Static和使用技巧

标签:people   int   div   turn   创建   highlight   struct   class   创建类型   

原文地址:https://www.cnblogs.com/allyh/p/10680130.html

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