简体   繁体   English

Extjs中的容器与面板

[英]Container vs Panel in Extjs

I have a question about Extjs 我有一个关于Extjs的问题

I have read the official document on Sencha doc but I have some confusion about 2 kinds of Component .That's the Container and the Panel. 我已经阅读了关于Sencha doc的官方文档,但我对2种Component有些困惑。那就是Container和Panel。

What is the difference between Container and Panel? Container和Panel有什么区别? Which should be used in which case? 在哪种情况下应该使用哪种?

Any answer are very appreciated. 任何答案都非常感谢。

Excerpt from the documentation of Container : 容器文档摘录:

Base class for any Ext.Component that may contain other Components. 任何可能包含其他组件的Ext.Component的基类。 Containers handle the basic behavior of containing items, namely adding, inserting and removing items. 容器处理包含项目的基本行为,即添加,插入和删除项目。

The most commonly used Container classes are Ext.panel.Panel , Ext.window.Window and Ext.tab.Panel. 最常用的Container类是Ext.panel.Panel ,Ext.window.Window和Ext.tab.Panel。 If you do not need the capabilities offered by the aforementioned classes you can create a lightweight Container to be encapsulated by an HTML element to your specifications by using the autoEl config option. 如果您不需要上述类提供的功能,则可以使用autoEl config选项创建一个轻量级容器,以便通过HTML元素将其封装到您的规范中。

This means, that the Panel extends the Container, meaning it can do more stuff. 这意味着,Panel扩展了Container,这意味着它可以做更多的事情。 For example it has a header and supports dokedItems (ie toolbars), can be closed (compare also the other events of the two components), while the container does not have by default such things. 例如,它有一个头并支持dokedItems(即工具栏),可以关闭(比较两个组件的其他事件),而容器默认没有这样的东西。

The general rule of thumb is: use simple containers always when you do not need the features of the panel, ie when you just need to host other children. 一般的经验法则是:当您不需要面板的功能时,即在您只需要托管其他孩子时,总是使用简单的容器。

Always remember that panels much heavier than container. 永远记住面板比容器重得多。 Therefore use it only needed. 因此只需要使用它。

Andrei I has explained the process pretty well and here is one more documentation . Andrei我已经很好地解释了这个过程,这里还有一个文档 On this documentation, Sencha team details how to choose correct class to extend for three of these widgets: Component , Container & Panel . 在此文档中,Sencha团队详细说明了如何选择正确的类来扩展其中三个小部件: ComponentContainerPanel

Which Class To Extend 要扩展哪个类

Choosing the best class to extend is mainly a matter of efficiency, and which capabilities the base class must provide. 选择要扩展的最佳类主要是效率问题,以及基类必须提供的功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM