Immutable.Map.deleteAll()不是一个函数 [英] Immutable.Map.deleteAll() is not a function
问题描述
考虑以下代码:
const person = Immutable.Map({
name: 'John',
surname: 'Maverick',
age: 39
});
const mutated = person.deleteAll(['name', 'age']);
预期结果将是突变
现在是删除了一个新的地图实例,其中包含密钥 name
和 age
。但是,抛出一个例外:
Expected result would be that mutated
now is a new instance of Map with the keys name
and age
deleted. However, throws an exception:
未捕获TypeError:person.deleteAll不是函数
Uncaught TypeError: person.deleteAll is not a function
当检查 Immutable.Map
原型的可用方法时,没有 deleteAll
或 removeAll
方法。是否已被删除?
When inspecting the available methods of Immutable.Map
prototype, there is no deleteAll
nor removeAll
methods. Have they been removed?
该方法列在官方ImmutableJS文档中,但不可用。在这种情况下,什么是本土不变的替代品?
谢谢。
The method is listed in the official ImmutableJS documentation, but it is not available. What would be a native Immutable alternative in this case? Thank you.
推荐答案
看起来它只是添加在最新版本( ver 4 RC1& RC2
)。我查看了 src
代码,并没有在 3.8.1
中找到。除非您要使用 4.0.0-rc.2
,否则没有其他方法可以使用该方法。
Looks like it's only been added on the latest version (ver. 4 RC1 & RC2
). I looked over the src
code and it's not found in the 3.8.1
. Unless you want to use 4.0.0-rc.2
, there's no other way to use that method yet.
这篇关于Immutable.Map.deleteAll()不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!