导航视图中的 Push Pop 操作 Sencha Touch

Push Pop operations in Naviagtion view Sencha Touch

我正在尝试使用导航视图并在其上执行推送和弹出操作,但无法找到我可以准确定义对象视图的位置,它将用于 view.push 和 view.pop. 因为我收到此视图未定义的错误! 如果试图将 Third_Navigate 定义为像

这样的 var 视图
var view = Ext.define('MyFirstApp.view.Third_Naviagte', { .. });

然后我收到错误 view.push 未定义。帮助。

Ext.define('MyFirstApp.view.Third_Naviagte', {
extend: 'Ext.navigation.View',
xtype: 'navigationview',
//itemId:'navView',
//we only give it one item by default, which will be the only item in the 'stack' when it loads
config:{
items: [
    {
        //items can have titles
        title: 'Navigation View',
        padding: 10,

        //inside this first item we are going to add a button
        items: [
            {
                xtype: 'button',
                text: 'Push another view!',
                handler: function() {
                   //when someone taps this button, it will push another view into stack
                    view.push({
                        //this one also has a title
                        title: 'Second View',
                        padding: 10,

                        //once again, this view has one button
                        items: [
                            {
                                xtype: 'button',
                                text: 'Pop this view!',
                                handler: function() {
                                    //and when you press this button, it will pop the current view (this) out of the stack
                                    view.pop();
                                }
                            }
                        ]
                    });
                }
            }
        ]
    }
]}

});

你的 var view = Ext.define(...); 示例不起作用的原因是 Ext.define 不同于 Ext.create 不是 return 对象实例。应该是 var view = Ext.create(...);.

另一种方法是使用 selecting 祖先使用的 up 方法。

在您的处理程序函数中使用 this 获取按钮实例,然后您可以从那里 select 导航视图,如下所示:

handler: function() {
    var view = this.up('navigationview');
    view.push({
        title: 'Second View',
        padding: 10,
        items: [
            {
                xtype: 'button',
                text: 'Pop this view!',
                handler: function() {
                    view.pop();
                }
            }
        ]
    });
}