0

我的观点有问题。我可以在网络中看到所有 .js 文件加载,并且 station.json 加载成功。但是我的页面没有任何数据!!!

我记得它在 ST2.0.0 中工作,但我使用的是 sencha touch 2.2.1,不工作

任何建议将不胜感激。谢谢。

  //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
    }
    ]

}
4

1 回答 1

0

我认为它不起作用,因为 homeview 扩展Ext.Panel,您可能想要扩展Ext.List

希望能帮助到你-

于 2013-08-27T16:20:04.517 回答