gpt4 book ai didi

extjs - 使用 store sencha touch 2 将数据加载到列表中

转载 作者:行者123 更新时间:2023-12-05 00:35:03 27 4
gpt4 key购买 nike

我已经使用 Sencha touch 2 创建了导航 View 。导航 View 具有列表组件,我想使用商店和模型加载它。我根据需要创建了模型和存储。在运行我的应用程序时,列表不会呈现任何数据。
它还在控制台中发出警告 [Ext.dataview.List#applyStore] The specified Store cannot be found .我不确定这个错误是什么意思。
这是我的 mvc 代码,

模型:

Ext.define('GS.model.BlogModel', {
extend: 'Ext.data.Model',

config: {
fields: [
{name: 'title', type: 'auto'},
{name: 'author', type: 'auto'},
{name: 'content', type:'auto'}
]
}
});

店铺:
Ext.define('GS.store.blogs',{
extend:'Ext.data.Store',
config:{
model:'GS.model.BlogModel',
autoLoad :true,
proxy:{
type:'jsonp',
url:'https://ajax.googleapis.com/ajax/services/feed/load?v=1.0&q=http://feeds.feedburner.com/SenchaBlog',
reader:{
type:'json',
rootProperty:'responseData.feed.entries'
}
}
}
});

看法:
Ext.define('GS.view.Blog',{
extend:'Ext.navigation.View',
xtype:'blog',
requires:[
'Ext.dataview.List',
'Ext.data.proxy.JsonP',
'Ext.data.Store',
'GS.store.blogs'
],
config: {
title:'Blog',
iconCls:'star',
items:{
xtype:'list',
itemTpl:'{title}',
title:'Recent Posts',
store:'GS.store.blogs'
}

}
});

有人可以指出我缺少什么/
任何帮助表示赞赏。

最佳答案

store房产在items因为您的列表需要是一个实例,而不是类的名称。 GS.store.blogs是类名。您需要使用 Ext.create 创建此类的实例。并在 items 中传递该实例.哦,是的,还有 items 的语法也是错的。需要是一个数组 []不是对象 {} .所以像:

var blogsStore = Ext.create("GS.store.blogs"); //put this in the items list

Ext.define('GS.view.Blog',{
extend:'Ext.navigation.View',
xtype:'blog',
requires:[
'Ext.dataview.List',
'Ext.data.proxy.JsonP',
'Ext.data.Store',
'GS.store.blogs'
],
config: {
title:'Blog',
iconCls:'star',
items:[{
xtype:'list',
itemTpl:'{title}',
title:'Recent Posts',
store: blogsStore //Store instance here. And items are in array, not Object
}]

}
});

关于extjs - 使用 store sencha touch 2 将数据加载到列表中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9958949/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com