访问Sencha Touch中的静态属性

nsg*_*nsg 6 extjs sencha-touch-2

如何在类中创建静态字段,然后在Sencha Touch 2中从该类外部访问它们?

例如,我创建了一个带有单个静态的简单单例:

Ext.define('App.util.Config', {
    singleton: true,
    statics: {
        url: {
            USER: 'http://localhost:3436/api/user'
        }
    },
    config: { },
    constructor: function (config) {
        this.initConfig(config);
        this.callParent([config]);
    }
});
Run Code Online (Sandbox Code Playgroud)

我无法使用App.util.Config.url.USER访问USER字段,但使用App.util.Config.self.url.USER.查看Sencha文档上的示例,看起来我应该能够以前一种方式访问​​该字段:

请参阅此链接中的静态部分以及它们如何访问Computer.InstanceCount字段

Ram*_*eya 6

我想这就是你想要的

Ext.define('App.util.Config', {
    singleton: true,
    statics: {
        url: {
            USER: 'http://localhost:3436/api/user'
        }
    },
    config: { },
    constructor: function (config) {
        var user=this.self.url.User;
    }
});
Run Code Online (Sandbox Code Playgroud)