W jaki sposób utworzyć pola statyczne w klasie, a następnie uzyskać do nich dostęp spoza tej klasy w Sencha Touch 2?Uzyskiwanie dostępu do właściwości statycznych w Sencha Touch
Na przykład Stworzyłem prosty singleton z jednego statycznego:
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]);
}
});
nie mogę uzyskać dostęp do pola Użytkownik korzystający App.util.Config.url.USER ale z App.util.Config .self.url.USER. Patrząc na próbce na docs Sencha, wydaje się, że powinienem być w stanie uzyskać dostęp do pola w dawnej sposób:
See Statics Section in this link and how they access the Computer.InstanceCount field
działa dobrze dla mnie. Czy plik App.util.Config.url jest niezdefiniowany? Co zwraca App.util.Config.self? –
App.util.Config.url \t 'undefined' App.util.Config.self \t' funkcyjnych() { \t powrotu this.constructor.apply (wspomniane argumenty); \t} ' App.util.Config.self.url.USER \t' "http: // localhost: 3436/api/user" ' – Nate
Jeden inny kawałek informacji, które mogą być istotne, nie jestem' Ext. create (...) 'this class, ale wymaga tego w app.js' wymaga: [ 'Ext.MessageBox', 'App.data.ConnectionRouter', 'App.util.Config' ], ' – Nate