7
我有一個ExtJS單例類。爲什麼我的ExtJS單身人士不工作?
作爲一個測試,我在app.js launch()函數中調用它的方法。
但是沒有定義單例靜態方法。
我想當我要求班級單身人士變得活躍?
Ext.Loader.setConfig({
enabled : true,
paths: {
'AM': 'app'
}
});
Ext.application({
name: 'AM',
autoCreateViewport: true,
requires: [
'AM.localization.ResourceManager'
],
controllers: [
'Users'
],
launch: function() {
alert(ResourceManager.initBundleLoader());
}
});
Ext.define('AM.localization.ResourceManager', {
alternateClassName: 'ResourceManager',
singleton: true,
init: function() {
this.initBundleLoader();
},
statics: {
test: 'here',
initBundleLoader: function() {
debugger;
Ext.applyIf(Ext.Loader, {
resourceBundles: new Object()
});
},
registerBundle: function(bundleName, locale) {
debugger;
if(!Ext.Loader.hasOwnProperty('resourceBundles')) {
this.initBundleLoader();
}
if(!Ext.Loader.resourceBundles.hasOwnProperty(bundleName)) {
if(Ext.ClassManager.isCreated('AM.locale.' + locale + '.resources.' + bundleName)) {
this.resourceBundles.bundleName = Ext.create('AM.locale.' + locale + '.resources.' + bundleName);
}
}
}
}
});
現在效果很好。謝謝你的幫助! –