我对Sencha Architect 3.0很新,我想设置一个MyApp.globals变量(在启动方法时启动)作为我商店的参数。像这样:
Ext.define('MyApp.store.myCustomer', {
extend: 'Ext.data.Store',
requires: [
'MyApp.model.Customer',
'Ext.data.proxy.Ajax',
'Ext.data.reader.Json'
],
config: {
model: 'MyApp.model.Customer',
storeId: 'myCustomer',
proxy: {
type: 'ajax',
//global variable as parameter
extraParams: {
salesman: MyApp.globals.Salesman
},
url: 'http://localhost:96/OrdApplication/customer_list.php',
reader: {
type: 'json',
rootProperty: 'items'
}
}
}
});
这是我的启动方法
launch: function() {
MyApp.globals = {
count: 1,
Salesman :0
};
Ext.create('MyApp.view.MainView', {fullscreen: true});
}
});
虽然这个商店在发布时不会加载任何东西,但是第一个视图都没有,但它似乎仍在加载,因为我在启动时遇到以下错误:
未捕获的TypeError:无法读取未定义的属性“Salesman” sencha-touch.js:8619未捕获错误:即使已加载文件,也未声明以下类:'MyApp.store.myCustomer'。
如何处理在变量声明发生之前没有加载存储的问题。事实上,如果有人能告诉我在按下按钮时动态加载商店并用它填充选择字段,那就太好了。