我的代码是,
Ext.define('notification_list_model', {
extend: 'Ext.data.Model',
fields: [{ name: 'firstName', type: 'string' },
{ name: 'lastName', type: 'string' }]
});
var notification_list_store = new Ext.data.Store({
model: notification_list_model,
data: [
{ firstName: 'Berkan', lastName: 'Kahya' },
{ firstName: 'Ahmet', lastName: 'Mutlu' },
{ firstName: 'Ahmet', lastName: 'Mutlu' },
{ firstName: 'Ahmet', lastName: 'Mutlu' }
],
});
var notification_list = new Ext.List({
store: notification_list_store,
itemTpl: '<div>{firstName}</div>',
flex: 1
});
listview查看数据,但firstName文本无法打印
答案 0 :(得分:0)
不要忘记使用sencha documentation。
<强>模型强>
Ext.define('notification_list_model', {
extend: 'Ext.data.Model',
config : {
fields: [{ name: 'firstName', type: 'string' },
{ name: 'lastName', type: 'string' }]
}
});
商品强>
var notification_list_store = new Ext.data.Store({
model:'notification_list_model',
data: [
{ firstName: 'Berkan', lastName: 'Kahya' },
{ firstName: 'Ahmet', lastName: 'Mutlu' },
{ firstName: 'Ahmet', lastName: 'Mutlu' },
{ firstName: 'Ahmet', lastName: 'Mutlu' }
],
});
<强>列表强>
var notification_list = new Ext.List({
store: notification_list_store,
itemTpl: '<div>{firstName}</div>',
flex: 1
});
Ext.Viewport.add(notification_list);
答案 1 :(得分:0)
我发现了问题,我在模型中写了{name}但我在List中调用了{firstName},所以
Ext.define('notification_list_model', {
extend: 'Ext.data.Model',
config : {
fields: [{ name: 'firstName', type: 'string' },
{ name: 'lastName', type: 'string' }]
}
});
新模式:
Ext.define('notification_list_model', {
extend: 'Ext.data.Model',
config: {
fields: ['firstName', 'lastName'],
}
});