Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/elixir/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sencha touch Sencha touch:无法获取对面板中项目的引用_Sencha Touch - Fatal编程技术网

Sencha touch Sencha touch:无法获取对面板中项目的引用

Sencha touch Sencha touch:无法获取对面板中项目的引用,sencha-touch,Sencha Touch,我正在尝试让MVC在我的第一个应用程序中工作,并尝试更改工具栏中单击的基于卡片的按钮 单击工具栏中的“hello”或“world”按钮时出现运行时错误:TypeError:无法读取行中未定义的属性“items”: var exerciseListPanel=this.items.items[0],//此处有代码错误 我在获取对面板中项目的引用时遇到问题,为什么? 以下是面板的完整代码: MyApp.views.HomeScreenPanel = Ext.extend(Ext.Pa

我正在尝试让MVC在我的第一个应用程序中工作,并尝试更改工具栏中单击的基于卡片的按钮

单击工具栏中的“hello”或“world”按钮时出现运行时错误:TypeError:无法读取行中未定义的属性“items”:
var exerciseListPanel=this.items.items[0],//此处有代码错误

我在获取对面板中项目的引用时遇到问题,为什么?

以下是面板的完整代码:

        MyApp.views.HomeScreenPanel = Ext.extend(Ext.Panel, {
        layout : 'card',
        cardSwitchAnimation: 'slide',
        initComponent : function() {
            this.dockedItems = this.buildDockedItems();
            this.items = this.buildItemList();
            MyApp.views.HomeScreenPanel.superclass.initComponent.call(this);
        },
        buildItemList : function(){
            return [
                new Ext.Panel({html:"hello"}),
                new Ext.Panel({html:"world"}),
            ];
        },
        buildDockedItems : function(){
            return [
                this.buildTopDockToolbar(),
                this.buildBottomDockToolbar(),
            ];
        },
        buildTopDockToolbar : function(){
            return {
                xtype : 'toolbar',
                dock  : 'top',
                title : 'My first MVC app',
            };
        },
        buildBottomDockToolbar : function(){
            return this.NavigationToolbar();
        },
        NavigationToolbar : function(){
            return{
                xtype : 'toolbar',
                dock : 'bottom',
                defaults : {
                    handler : this.NavigationToolbarHandler,
                    controller: 'NavigationBarController'
                },
                items : [
                {
                    text : 'hello',
                    action: 'hello'
                },
                {
                    text : 'world',
                    action : 'world'
                }]
            };
        },    
        NavigationToolbarHandler : function(btn) {

            var exerciseListPanel = this.items.items[0], // CODE ERRORS HERE!
                workoutListPanel  = this.items.items[1];

            Ext.dispatch({
                controller :     btn.controller,
                action :         btn.action,
               views : {
                    exerciseListPanel: exerciseListPanel,
                    workoutListPanel: workoutListPanel,
               }
            })
        },
    });

    Ext.reg('HomeScreenPanel',MyApp.views.HomeScreenPanel);

Here is the code for the controller but I don't there is a problem here:

Ext.regController('NavigationBarController', {
    world : function(dataObj) {
        Ext.Msg.alert(
            'world!',
            'world button pressed from toolbar',
            Ext.emptyFn
        );
        MyApp.views.HomeScreenPanel.setActiveItem(dataObj.views.worldPanel); // CORRECT SYNTAX????


    },
    hello : function(dataObj) {
        Ext.Msg.alert(
            'hello',
            'hello button pressed',
            Ext.emptyFn
        );
        MyApp.views.HomeScreenPanel.setActiveItem(dataObj.views.helloPanel); // CORRECT SYNTAX?????

    }
});

这可能只是一个范围问题。尝试:

exerciseListPanel = MyApp.views.HomeScreenPanel.items.items[0];

在此上下文中,此
可能是按钮。

项是一个混合集合,因此请使用get函数。

有点晚了,但对将来谷歌搜索的其他人来说;)

MyApp.views.HomeScreenPanel.items.get(0);