Sencha touch 2 使用sencha touch2销毁一个视图后,如何显示另一个视图

Sencha touch 2 使用sencha touch2销毁一个视图后,如何显示另一个视图,sencha-touch-2,Sencha Touch 2,我的主视图包含以下代码 items: [ { xtype:'headerpage', docked:'top' }, { // this is the content area... id: 'launchscreen', cls : 'card', scrolla

我的主视图包含以下代码

items: [
            {
                xtype:'headerpage',
                docked:'top'
            },
            {  // this is the content area...
                id: 'launchscreen',
                cls : 'card',
                scrollable: true,
               xtype:'informationpage'
            },
            {
                docked:'left',
                xtype:'page1',
                store: 'page1'
            }

        ],
在商店里我有两个按钮第1页,第2页

当我单击page2按钮时,它应该显示page2视图,我尝试了以下操作

 control: {
       '#page2id':{
                tap:function(){
                    Ext.getCmp('launchscreen').destroy();
                    Ext.Viewport.add(Ext.create('App.view.page2'));
                   // Ext.Viewport.add('App.view.Page2');
                }
            }
} 

使用上述启动屏幕会被破坏,但第2页不会显示在启动屏幕的位置。有人能帮我吗…提前谢谢。

目前,您刚刚在
视口中添加了新视图,您还需要使用来显示
第2页
视图:

Ext.getCmp('launchscreen').destroy();
var page2 = Ext.Viewport.add(Ext.create('App.view.page2'));
Ext.Viewport.setActiveItem(page2); 
或者,您可以使用指定的动画设置
视口的动画,例如:

Ext.Viewport.animateActiveItem(page2, {type: 'slide', direction: 'right'}); 

将ID添加到launchscreen所在的容器中:

id: 'mainContainer',
items: [
            {
                xtype:'headerpage',
                docked:'top'
            },
            {  // this is the content area...
                id: 'launchscreen',
                cls : 'card',
                scrollable: true,
               xtype:'informationpage'
            },
            {
                docked:'left',
                xtype:'page1',
                store: 'page1'
            }

        ],
然后,您可以将第二页添加到容器中:

控制器代码:

 control: {
           '#page2id':{
                    tap:function(){
                        Ext.getCmp('launchscreen').destroy();
                        var page2 = Ext.getCmp('mainContainer').add(Ext.create('App.view.page2'));
                        Ext.getCmp('mainContainer').setActiveItem(page2); 
                    }
                }
    } 

user1479606,谢谢你的回答,是的,现在当我单击按钮page2时,它会在新屏幕中显示视图。但它应该在启动屏幕的相同位置显示page2。卢卡斯K,现在,我遇到另一个问题。当我单击page2按钮时,它会显示page2视图。之后,我单击了page1按钮,它不会打开page1视图。另一件有趣的事情是,在重新加载应用程序后,如果我单击page1,它会显示page1视图,然后我单击了page2按钮,但它不起作用。你能帮我解决这个问题吗…你能发布你的视图代码和你的控制器吗?我修复了它。首先,我将第二页的id更改为“page2id”,因为“page2”仍处于另一个位置。然后我改变了你控制器的功能。控制器中的问题是,在第二次单击时,启动屏幕仍然被破坏,javascript因此停止