Ext4 类的静态成员属性 statics

可通过Ext.Class.statics属性来设置类的静态成员

Ext.define("A", {
    statics: {
         count: 0,
         appName: "A"
    },
    constructor: function(){
         ++this.self.count; 或 ++this.statics().count;
    },
    getCount: function(){
         return this.statics().count;
    },
    getAppName: function(){
         return this.self.appName;
    }
});

类定义内部不能使用"this.statics.成员名"的方式访问静态成员,而要使用"this.self.静态成员名"或"this.statics().静态成员名";
类定义外部使用"类名.静态成员名"来访问类静态成员。

发布了51 篇原创文章 · 获赞 10 · 访问量 9万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章