ExtJS 4 选择元素的最佳方式 [英] ExtJS 4 Best way to select an element
本文介绍了ExtJS 4 选择元素的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在代码中(如果重要,我使用 MVC 模型),为了获取特定元素,我使用 refs.
In the code (I use MVC model if it matters), to get a specific elements, I use refs.
refs: [
{
ref: 'window',
selector: 'windowName'
},
{
ref: 'windowButton',
selector: 'windowName button[name=buttonName]'
},
{
ref: 'windowCombo',
selector: 'windowName combo[name=comboName]'
}
]
这是获取元素的正确选择吗?或者我必须使用 getCmp() 或其他什么?
Is this the right choice to get an elements? Or I have to use getCmp() or something else?
推荐答案
这里有一些关于在应用中定位组件的提示.
Here are some tips on targeting a component in an app.
首先要非常小心地在组件上使用 ID.我已经看到我与他们分享的问题.不惜一切代价避免.
其次,ExtJS 提供了多种定位方式组件 和 元素.不要将两者混为一谈.
Second, ExtJS provides several ways of targeting Components and Elements. Don't mix the two.
For Components:
• Ext.getCmp(id)
• Ext.ComponentQuery.query()
• up()
• down()
• nextSibling()
• previousSibling()
• child()
• previousNode()
plus various find.. Methods
For Elements:
• Ext.get()
• Ext.dom.Query()
(更多关于 DOM 查询 http://docs.sencha.com/核心/手册/内容/domquery.html
(more on DOM Query http://docs.sencha.com/core/manual/content/domquery.html
这篇关于ExtJS 4 选择元素的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文