gpt4 book ai didi

javascript - ExtJs 4,有没有办法找到控件? (不是 "id")

转载 作者:搜寻专家 更新时间:2023-11-01 04:44:18 27 4
gpt4 key购买 nike

我有一个带有 id = 'someid' 的按钮,我可以通过 Ext.getCmp('someid') 找到它...

有没有办法为该按钮设置某种“extraId”,并通过“extraId”找到该按钮?

最佳答案

问题是您想在哪里搜索以获取您的元素。

另一种方式可能是 itemId

An itemId can be used as an alternative way to get a reference to a component when no object reference is available. Instead of using an id with Ext.getCmp, use itemId with Ext.container.Container.getComponent which will retrieve itemId's or id's. Since itemId's are an index to the container's internal MixedCollection, the itemId is scoped locally to the container -- avoiding potential conflicts with Ext.ComponentManager which requires a unique id.

来源和更多文档:http://docs.sencha.com/ext-js/4-0/#/api/Ext.AbstractComponent-cfg-itemId

ComponentQuery(由 wombleton 提到)也是一种好方法,但性能可能不如 itemId

关于javascript - ExtJs 4,有没有办法找到控件? (不是 "id"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5789183/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com