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萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章