我正在使用MVC架构将数据加载到列表中,并将其显示在屏幕上。 运行应用程序后,我收到以下错误
[WARN] [test.view.list #applyStore]无法找到指定的商店
我尝试按照here给出的说明,但它给了我错误:
在null / view / list.js找不到文件null / store / list1store.js null / model / list1modeljs
应用程序的根目录是" test"。
列出模型文件:
Ext.define('test.model.list1model', {
extend: 'Ext.data.Model',
config: {
fields: [
{name: 'firstName', type: 'string'},
{name: 'lastName', type: 'string'},
{name: 'age', type: 'int'},
{name: 'eyeColor', type: 'string'}
]
}
});
列出商店文件:
Ext.define("test.store.list1store", {
extend:'Ext.data.Store',
requires:['test.model.list1model'],
config:{
model: "test.store.list1model",
data : [
{firstName: "Ed", lastName: "Spencer"},
{firstName: "Tommy", lastName: "Maintz"},
{firstName: "Aaron", lastName: "Conran"},
{firstName: "Jamie", lastName: "Avins"}
]
}
});
列表视图文件:
Ext.define("test.view.list", {
extend:'Ext.List',
requires:['test.store.list1store'],
config:{fullscreen: true,
store: 'test.store.list1store',
itemTpl: "{lastName}, {firstName}"
}
});
app.js:
Ext.application({
requires: [
'Ext.dataview.List',
'Ext.Panel',
'Ext.Spacer',
'test.view.list',
'Ext.List',
'test.model.list1model',
'test.store.list1store'
],
launch : function(){
list1 =Ext.create('test.view.list');
Ext.create('Ext.Container',{
id:'contain',
fullscreen:true,
items:[
list1,
]
})
}
});
答案 0 :(得分:3)
您只定义了一个商店,但没有实例化它。请尝试以下方法:
Ext.define("test.view.list", {
extend:'Ext.List',
requires:['test.store.list1store'],
fullscreen: true,
constructor : function() {
this.callParent();
this.setStore(Ext.create("test.store.list1store"));
},
config: {
fullscreen: true,
itemTpl: "{lastName}, {firstName}"
}
});
PS:在商店中将您的模型更正为:model: "test.model.list1model"