“applyTo”之间的区别和“contentE1”在extJS [英] Difference between "applyTo" and "contentEl" in extJS

查看:134
本文介绍了“applyTo”之间的区别和“contentE1”在extJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在extJS中 applyTo contentEl 之间有什么区别?它们是面板的两个配置属性。

What is the difference between applyTo and contentEl in extJS? They are two config properties of the panel.

推荐答案

applyTo 面板成为目标元素(面板主体仍然可以包含任何内容), contentEl 使用目标元素作为其主体内容(面板仍可以呈现给任何其他元素) 。这两种方法是无关的。

applyTo renders the panel into a target element (the panel body could still contain any content), contentEl uses the target element as its body content (the panel could still be rendered to any other element). The two methods are unrelated.

编辑:只需要注意,从Ext 4.0+起, applyTo config不再存在。随着时间的推移,声明/逐步增强策略对于Ext来说变得不那么可行(它从来没有在所有组件中得到完全支持),并且终于停止了它的支持。您将始终使用 renderTo (以编程方式呈现到目标元素),而 contentEl 仍然有效,仍然表示要从中获取内容的元素将其添加到面板的正文中。 contentEl 是最有用的,当您在页面上显示一些现有的HTML,而不需要重现内容标记JS代码

Edit: Just a note that as of Ext 4.0+ the applyTo config no longer exists. As time went on, the declarative / progressive enhancement strategy became less viable for Ext (it never was fully supported in all components anyway), and they finally stopped supporting it. You would always use renderTo now (to render programmatically to a target element), whereas contentEl is still valid and still indicates the element from which to take content and add it into the panel's body.contentEl is most useful when you have some existing HTML on the page that you want to display inside a Panel component without having to reproduce the content markup in JS code.

当我在这里,我想我会澄清别的东西...重要的是要了解 renderTo 通常只被应用程序布局中最顶层的容器使用。所有子组件应始终添加为 项目 到容器 - 通过 renderTo 将子组件直接呈现到目标元素意味着这些组件不会参与您通常不想在应用程序中进行管理的布局系统。

While I'm here, I suppose I'll clarify something else... It's important to understand that renderTo is typically only used by the top-most container in an application layout. All child components should always be added as items to a Container -- rendering child components directly to a target element via renderTo means that those components will not participate in the Ext-managed layout system, which you typically do NOT want in an application.

另一个区别是Ext中的每个组件都支持 renderTo ,但只有某些组件(最有用的Panel)将以有意义的方式履行 contentEl 。即使 contentEl AbstractComponent 中定义,大多数组件不是设计为处理任意HTML内容。

Another difference is that every component in Ext supports renderTo, but only certain components (most usefully Panel) will honor contentEl in a meaningful way. Even though contentEl is defined on AbstractComponent, most components are not designed to handle arbitrary HTML content.

这篇关于“applyTo”之间的区别和“contentE1”在extJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆