搜索MixedCollection中的项目

问题描述:

我使用Ext JS,所以搜索MixedCollection中的项目

我有一个带有项目(按钮,标签等)的工具栏。我元素添加到工具栏是这样的:

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")); 

并没有任何保证,这个集合中的每个元素都有这个字段。

使用findBy方法:

toolbar.items.findBy(c => c.ref == 'the value you want'); 

还有其他的方法来谈论对容器子项,但它取决于分机版本,你要找的是什么。

+0

也许你知道一些参考资料,我可以看到,如何制作功能,就像你所做的一样? – koshachok

+0

它被称为箭头函数,是es6的一部分,请参阅https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions –