我的观点出了问题。 我可以看到网络中的所有.js文件加载,并且station.json加载成功。 但我的页面没有任何数据!!!
我记得它在ST2.0.0中有效,但我正在使用 sencha touch 2.2.1,没有工作
任何建议都会受到赞赏。 thx。
//app/view/homeview.js
Ext.define('Sencha.view.homeview', {
extend: 'Ext.Panel', //error1 should extend Ext.List
xtype:'homeviewpanel',
alias: 'widget.homeview',
layout:'vbox', //error2 should not have this line ,
config:
{
title:'Home',
iconCls:'home',
cls:'home',
store:'homestore',
itemTpl:'{name}<br/>{age}',
},
initialize: function() {
console.log('initialize home view');
this.callParent(arguments);
}
});
//app/store/homestore.js
Ext.define('Sencha.store.homestore', {
extend: 'Ext.data.Store',
config:{
model: 'Sencha.model.homemodel',
proxy: {
type:'ajax',
url:'data/stations.json',
reader:{
type:'json',
rootProperty:"users"
}
},
autoLoad: true,
}
});
//app/cotroller/maincontroller.js
Ext.define('Sencha.controller.maincontroller',{
extend:'Ext.app.Controller',
launch: function () {
this.callParent(arguments);
}
});
//app.view.viewport.js
Ext.define('Sencha.view.viewport',{
// extend:'Ext.Container',
// requires:['Ext.TabPanel'],
extend:'Ext.TabPanel',
config:{
fullscreen:true,
tabBarPosition:'bottom',
items:[
{
xtype:'homeviewpanel'
},
]
}
});
//app/app.js
Ext.Loader.setConfig({ enabled: true });
// Main application entry point
Ext.application({
name: 'Sencha',
controllers:['maincontroller'],
views:['homeview'],
stores:['homestore'],
models:['homemodel'],
launch: function() {
Ext.create('Sencha.view.viewport');
}
});
//app/model/homemodel.js
Ext.define('Sencha.model.homemodel', {
extend: 'Ext.data.Model',
config:{
idProperty: 'id',
fields:[
{field:'name',type:'string'},//error 3 filed should be name
{field:'age',type:'number'}//error 3 filed should be name
]
}
});
//data/stations.json
{
"code": 1,
"msg": "",
"users": [ {
"id": 1,
"name": "navy",
"age": 18
},
{
"id": 2,
"name": "wade",
"age": 19
}
]
}