我用的是Ext JS,所以
我有一个带有项目(按钮、标签等)的工具栏。我像这样向工具栏添加元素:
toolbar.add(this.tempObject);
或者像这样:
toolbar.add({
xtype: button,
...
});
因此,我想通过字段"ref"
在此工具栏中查找一些元素。我试图:
toolbar.items.find(new Function("there should be my function, but i have no idea how to write it"));
并且没有 promise 这个集合中的每个元素都会有这个字段。
最佳答案
使用 findBy 方法:
toolbar.items.findBy(c => c.ref == 'the value you want');
还有其他方法可用于讨论容器上的子项,但这取决于 Ext 版本和您要查找的内容。
关于javascript - 在 MixedCollection 中搜索项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46642781/