javascript - sencha extjs 在 storemanager 完成加载后运行?
问题描述
在开发应用程序时,我在应用程序启动时运行一些代码:
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
任何商店。有什么办法可以将其“延迟”到 storemanager 已完全加载并且这些商店不再返回 undefined 的程度?(商店本身不会充满数据......)。
解决方案
只需将其添加到 Ext.application 类或 TestApp.application (更好)
stores:['TestApp.store.Organization'],
这是您所有商店的数组,因此如果您需要添加更多商店,只需使用逗号并写入新文件的类路径名
这是一个工作示例小提琴
推荐阅读
- python - 忽略具有计算能力 3.0 的可见 gpu 设备。所需的最低 Cuda 能力为 3.5
- elixir - Distillery 未替换 systemd 版本中的变量
- antlr4 - ANTLR4:规则“规则”包含一个闭包,其中至少有一个可以匹配空字符串的替代方案
- excel - 调用退出函数时出错 | 递归的
- sql - Hiveql - 如何在字符串中只保留数字和空格
- python - 迭代数据框中的列以运行/追加计算
- visual-studio - 在 Visual Studio 中 NuGet 强制更新依赖包
- ios - 未从 Main.Storyboard 加载翻译(英文)
- .net - 如何防止 Windows 窗体充当 GC 根
- javascript - JSON & Javascript - 动态 DOM 操作