首页 > 其他 > 详细

TypeScript专题-Static和使用技巧

时间:2019-04-09 22:17:22      阅读:136      评论:0      收藏:0      [点我收藏+]
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和使用技巧

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!