[英]Loading data into List using store Sencha Touch 2 and don't appear
我遵循了這里發布的示例,該示例涉及使用商店Sencha Touch 2將數據加載到列表中,它似乎可以正常工作,但是當我嘗試執行相同操作時,則不會顯示任何內容
我是sencha接觸的新手,對此我不太了解。有人可以告訴我我做錯了什么嗎?
這是代碼:
主要:
var blogsStore = Ext.create("GS.store.blogs"); //put this in the items list
Ext.define('GS.view.Main',{
extend:'Ext.navigation.View',
xtype:'blog',
requires:[
'Ext.dataview.List',
'Ext.data.proxy.JsonP',
'Ext.data.Store',
'GS.store.blogs',
'GS.model.BlogModel'
],
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
}
]
}
});
模型:
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',
requires: [
'GS.model.BlogModel',
'Ext.data.proxy.JsonP',
],
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'
}
}
}
});
app.js:
Ext.application({
name: 'GS',
requires: [
'Ext.MessageBox'
],
views: [
'Main'
],
stores: [
'blogs'
],
models:[
'BlogModel'
],
icon: {
'57': 'resources/icons/Icon.png',
'72': 'resources/icons/Icon~ipad.png',
'114': 'resources/icons/Icon@2x.png',
'144': 'resources/icons/Icon~ipad@2x.png'
},
isIconPrecomposed: true,
startupImage: {
'320x460': 'resources/startup/320x460.jpg',
'640x920': 'resources/startup/640x920.png',
'768x1004': 'resources/startup/768x1004.png',
'748x1024': 'resources/startup/748x1024.png',
'1536x2008': 'resources/startup/1536x2008.png',
'1496x2048': 'resources/startup/1496x2048.png'
},
launch: function() {
// Destroy the #appLoadingIndicator element
Ext.fly('appLoadingIndicator').destroy();
// Initialize the main view
Ext.Viewport.add(Ext.create('GS.view.Main'));
},
onUpdated: function() {
Ext.Msg.confirm(
"Application Update",
"This application has just successfully been updated to the latest version. Reload now?",
function(buttonId) {
if (buttonId === 'yes') {
window.location.reload();
}
}
);
}
});
我在聲明rootProperty時發現錯誤,我嘗試訪問返回的json中的'entries'元素,但該屬性不存在,那么您應該修改rootProperty:
rootProperty:'responseData.feed'
現在應用程序的工作原理
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.