在开发应用程序时,我在应用程序启动时运行了一些代码:
Ext.application({
extend: 'TestApp.Application',
name: 'TestApp',
requires: [
'TestApp.*'
],
// The name of the initial view to create.
launch: async function () {
const store_org = Ext.getStore('Organizations');
const store_event = Ext.getStore('Events');
//more stuff here
}
});
这两个商店都有明确的定义:
Ext.define('TestApp.store.Organization', {
extend: 'Ext.data.Store',
storeId: 'Organizations',
alias: 'store.organizations',
model: 'TestApp.model.Organization',
autoLoad: true,
pageSize: 0,
proxy: {
type: 'ajax',
url: TestApp.util.Config.getHost() + '/organization/get-organizations',
withCredentials: true,
reader: {
type: 'json',
rootProperty: '',
},
},
});
但是,我确实注意到,在启动Ext.getStore()
函数时,始终返回任何商店的undefined
。有什么方法可以"延迟"到商店经理已完全加载并且这些商店不再返回未定义的点?(商店本身不会充满数据...
只需将其添加到 Ext.application 类或 TestApp.application 中(哪个更好(
stores:['TestApp.store.Organization'],
这是所有存储的数组,所以如果您需要添加更多只需使用逗号并写入新文件的类路径名
这是一个工作示例 小提琴