【问题标题】:Panels in Panels in Sencha Touch 2Sencha Touch 2 中的面板中的面板
【发布时间】:2012-05-13 05:28:19
【问题描述】:

我是 Sencha Touch 2 的新手,我想拥有类似的东西:

  • 一个列表(例如用于待办事项,仅用于试用 ST2),我可以在其中点击以进行编辑或将其设置为已完成等。

我不确定我做得对,但我想我有一个面板,其中左侧包含列表,右侧包含详细信息视图。查看 Conatiner 的文档:

//this is the Panel we'll be adding below
var aboutPanel = Ext.create('Ext.Panel', {
    html: 'About this app'
});

//this is the Panel we'll be adding to
var mainPanel = Ext.create('Ext.Panel', {
    fullscreen: true,

    layout: 'hbox',
    defaults: {
        flex: 1
    },

    items: {
        html: 'First Panel',
        style: 'background-color: #5E99CC;'
    }
});

//now we add the first panel inside the second
mainPanel.add(aboutPanel);

我想我也许可以使用config 属性来配置我的面板:

Ext.define("SimpleTodo.view.Main", {
    extend: 'Ext.Panel',
    config: {
        items: [
            {
                xtype: 'panel',
                config: {
                    html: 'Panel 1 ...'
                }
            },
            {
                xtype: 'panel',
                config: {
                    html: 'Panel 2 ...'
                }
            }
        ]
    }
});

失败:空白屏幕。如果我将html 属性添加到config 中,我会显示HTML,但是我在items 上做错了什么?

您可能还注意到,我有一个左侧列表和右侧详细信息列表。这对平板电脑很好,但我怎样才能让它适用于手机呢?我是否需要为它们使用配置文件和单独的视图?

【问题讨论】:

    标签: html sencha-touch extjs sencha-touch-2


    【解决方案1】:

    但是我对这些物品做错了什么?

    panel 组件没有 config 属性。因此,删除每个panel 的config 属性,并直接使用html 属性在每个panel 中设置html

    这样,

    {
      xtype: 'panel',
      html: 'Panel 1 ...'
    },
    {
      xtype: 'panel',
      html: 'Panel 2 ...'
    }
    

    【讨论】:

    • 实际上,这对我来说是 1 个困惑。 panel 和 Ext.Panel 一样吗?我在想它们是别名什么的,但是如果我使用 Ext.Panel 我会得到一个错误
    • 哦,关于config 和没有config 的事情,我怎么知道我应该向config: { ... } 添加属性还是将其放入对象属性中?
    • panel 是一个 xtype(类别名),Ext.Panel 是一个 REAL 类
    • @ThiemNguyen,所以我可以说当我使用xtype 时,任何进入config 的内容都应该简单地内联定义吗?喜欢上面的html 属性吗?
    • 是的,它等于:Ext.create('Ext.Panel',{html: 'test'});
    猜你喜欢
    • 2012-05-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多