How can I update list where element with name third have its count set to 4?推荐答案最合适的情况是同时使用 findIndex 和 update 方法.The most appropriate case is to use both findIndex and update methods.list = list.update( list.findIndex(function(item) { return item.get("name") === "third"; }), function(item) { return item.set("count", 4); });附言并非总是可以使用地图.例如.如果名称不是唯一的并且我想更新具有相同名称的所有项目.P.S. It's not always possible to use Maps. E.g. if names are not unique and I want to update all items with the same names. 这篇关于如何使用 ImmutableJS 更新 List 中的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-16 13:31
查看更多