Ext.getCmp(id)或Ext.ComponentQuery.query(attribute) [英] Ext.getCmp(id) or Ext.ComponentQuery.query(attribute)
问题描述
最好是避免直接使用这两个。 Ext.getCmp
特别被认为是代码气味。您应该努力组织您的代码,使其不需要它们。
组件查询优雅,但您应该使用父容器(从而减少研究树,并允许您利用相对 itemId
),或来自控制器。这是我的猜测,控制器是组件查询添加到Ext4的真正原因。
I am new to Extjs and using Extjs v4.2.0. To find an object I can use either Ext.getCmp(id) or Ext.ComponentQuery.query(attribute).Which one is better to use and faster?
The best is to avoid using any of this two directly. Ext.getCmp
is especially considered bad "code smell". You should strive to organize your code in such a way that you don't need them.
Component queries are elegant, but you should use them either from a parent container (thus reducing the research tree and allowing you to leverage relative itemId
), or from a controller. It is my guess that controllers are the true reason why component queries have been added to Ext4.
这篇关于Ext.getCmp(id)或Ext.ComponentQuery.query(attribute)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!