Sencha touch 2 在Sencha Touch 2中使用NavigationView

Sencha touch 2 在Sencha Touch 2中使用NavigationView,sencha-touch-2,sencha-touch-2.1,Sencha Touch 2,Sencha Touch 2.1,我正在试用Sencha Touch 2,但导航视图出现了问题,因为它不起作用。。。每次我尝试推送一个视图时,我都会得到错误uncaughttypeerror:无法调用undefined的方法'apply',我不知道为什么 如果我在导航视图的配置部分中初始化第一个视图,它可以正常工作,但是如果我尝试将完全相同的视图推送到NavigationView中,我会得到错误 以下是我的视图和控制器的一些代码: 控制员: Ext.define('svmobile.controller.MyController

我正在试用Sencha Touch 2,但导航视图出现了问题,因为它不起作用。。。每次我尝试推送一个视图时,我都会得到错误
uncaughttypeerror:无法调用undefined的方法'apply',我不知道为什么

如果我在导航视图的配置部分中初始化第一个视图,它可以正常工作,但是如果我尝试将完全相同的视图推送到NavigationView中,我会得到错误

以下是我的视图和控制器的一些代码:

控制员:

Ext.define('svmobile.controller.MyController', {
    extend: 'Ext.app.Controller',
    alias: 'widget.mycontroller',

    config: {
        refs: {
            mainView:   'main',
        }
    },

    launch: function() {
        this.callParent(arguments);
        Ext.Viewport.add(Ext.create('svmobile.view.Main'));
        this.getMainView().getNavigationBar().add(
            {
                xtype: 'navbutton',
                align: 'right'
            }
        );

        this.getMainView().push(       //This is not working
            {
                xtype: 'hostspie'
            }
        );
    },
...
导航视图:

Ext.define('svmobile.view.Main', {
    extend: 'Ext.navigation.View',
    xtype: 'main',
    alias: 'widget.main',

    config: {
        items: {               //This way it works
            xtype: 'hostspie'
        }
    }
});
要推送的视图:

Ext.define('modules.nagios.view.HostsPie', {
    extend: 'Ext.Panel',
    alias: 'widget.hostspie',

    requires: [
        ...
    ],

    config: {
        layout: 'fit',
        title: 'Dashboard',

        items: [
            {
                xtype: 'polar',
                ...
            }
        ]
    }
});
你知道为什么它不能正常工作吗?

你试着定义了吗

Ext.define('modules.nagios.view.HostsPie', {
extend: 'Ext.Panel',
alias: 'widget.hostspie',

xtype: 'hostspie',

谢谢你的建议。我终于明白了。是一个按钮的实现导致了这个问题。现在它工作了,谢谢

尝试执行console.log(this.getMainView().getNavigationBar())并查看这是作为对象还是未定义的
this.getMainView().getNavigationBar()
this.getMainView()
作为对象出现…仍然存在该问题。我发现该对象实际上已添加到视图中,但没有显示。它列在innerItems和items下的对象数据中。有趣的是:添加到导航栏的按钮起作用了,也许我必须在视图对象中更深一点才能推一个新视图?尝试给出一些固定的宽度和高度,然后看看它是否可见。另外,如果您可以在DOM中看到它,您是否可以检查CSS并查看它为什么不可见?尝试注释掉控制器中所有可能的回调。若您已经定义了回调函数,但并没有实现它,那个么可能会发生这种情况。