Model view controller 带页眉和页脚的Sencha Touch MVC应用程序

Model view controller 带页眉和页脚的Sencha Touch MVC应用程序,model-view-controller,header,sencha-touch,footer,Model View Controller,Header,Sencha Touch,Footer,我是新来Sencha Touch的。因此,我正在构建一个带有页眉和页脚的MVC应用程序。 现在,我尝试实现所有页面的标题: 首先,我有一个主面板视图: tagip.views.MainPanel = Ext.extend(Ext.Panel,{ layout: 'vbox', scroll: 'vertical', cls : 'general', initComponent: function () { Ext.apply(tagip.views, { header

我是新来Sencha Touch的。因此,我正在构建一个带有页眉和页脚的MVC应用程序。 现在,我尝试实现所有页面的标题:

首先,我有一个主面板视图:

tagip.views.MainPanel = Ext.extend(Ext.Panel,{
layout: 'vbox',
scroll: 'vertical',
cls : 'general',

initComponent: function () {

    Ext.apply(tagip.views, {
        header: new tagip.views.Header(),
        viewport : new tagip.views.Viewport()           
    });

    Ext.apply(this, {
        items: [
            tagip.views.header,
            tagip.views.viewport
        ]
    });

    tagip.views.MainPanel.superclass.initComponent.apply(this, arguments);  
  }
});
然后我有一个标题视图:

tagip.views.Header = Ext.extend(Ext.Panel, {
height: 20,
html : "<h1>Header</h1>",

   initComponent: function (){
       tagip.views.Header.superclass.initComponent.apply(this, arguments);  
   }
});
但是当我启动应用程序时,我只看到这个视口的内容,没有标题


有人能帮我吗?

我会将标题内容添加为xtype:toolbar或直接添加到docketItems:property。因为这是包含面板的一部分,所以其中包含的卡都将共享这些停靠项目

在主面板定义中:

// ...

cls: 'general',
dockedItems: [{
        html : "<h1>Header</h1>"
}],

// ...
/。。。
cls:'一般',
摘要:[{
html:“标题”
}],
// ...

我会将标题内容添加为xtype:toolbar或直接添加到docketItems:property。因为这是包含面板的一部分,所以其中包含的卡都将共享这些停靠项目

在主面板定义中:

// ...

cls: 'general',
dockedItems: [{
        html : "<h1>Header</h1>"
}],

// ...
/。。。
cls:'一般',
摘要:[{
html:“标题”
}],
// ...

处理此问题的最佳方法是创建并注册页眉/页脚面板

标题:

app.views.Navigation = Ext.extend(Ext.Panel, {
id: 'navigation',
height: '60',
layout: {
    type:'hbox',
    align:'stretch'
},
defaults:{flex:'1'},
style: 'text-align:center',
items: [
{
    html: '<a href="#">Item 1</a>'
},{
    html: '<a href="#">Item 2</a>'
},{
    html: '<a href="#">Item 3</a>'
}],  
initComponent : function() {
    app.views.Navigation.superclass.initComponent.apply(this, arguments);
}
});

Ext.reg('navigation', app.views.Navigation);

处理此问题的最佳方法是创建并注册页眉/页脚面板

标题:

app.views.Navigation = Ext.extend(Ext.Panel, {
id: 'navigation',
height: '60',
layout: {
    type:'hbox',
    align:'stretch'
},
defaults:{flex:'1'},
style: 'text-align:center',
items: [
{
    html: '<a href="#">Item 1</a>'
},{
    html: '<a href="#">Item 2</a>'
},{
    html: '<a href="#">Item 3</a>'
}],  
initComponent : function() {
    app.views.Navigation.superclass.initComponent.apply(this, arguments);
}
});

Ext.reg('navigation', app.views.Navigation);
app.views.Home = Ext.extend(Ext.Panel, {
scroll: 'vertical',
items: [{
    xtype: 'navigation'
},{
    xtype: 'panel',
html: '<p>this is your content</p>'
},{
    xtype: 'footer'
}],     
initComponent : function() {
    app.views.Home.superclass.initComponent.apply(this, arguments);
}
});

Ext.reg('home', app.views.Home);
var home = this.render({
        xtype: 'home',
        listeners: {
            deactivate: function(home) {
                home.destroy();
            }
        }
    });

    this.application.viewport.setActiveItem(home);