IE 11 的 Map(iterable) 替代品
Map(iterable) alternative for IE 11
不幸的是我必须支持IE11。
我使用此代码创建我的地图(已使用 .entries 的 polyfill):
const map = new Map(Object.entries(array));
但由于 IE11 不支持 iterable 构造函数,Map 为空。
我找不到 polyfill 或其他任何东西。谁有解决这个问题的简单方法?
之后我像这样使用 map
:
map.forEach((maps: ITopoInterface[], key: string) => {
maps.findIndex((t: ITopoInterface) => {
//do stuff
});
});
你说这是空的:
const map = new Map(Object.entries(array));
您是否尝试过自己添加值?
const map = new Map();
Object.entries(array).forEach(entry => {
map.set(entry[0], entry[1]);
});
不幸的是我必须支持IE11。
我使用此代码创建我的地图(已使用 .entries 的 polyfill):
const map = new Map(Object.entries(array));
但由于 IE11 不支持 iterable 构造函数,Map 为空。
我找不到 polyfill 或其他任何东西。谁有解决这个问题的简单方法?
之后我像这样使用 map
:
map.forEach((maps: ITopoInterface[], key: string) => {
maps.findIndex((t: ITopoInterface) => {
//do stuff
});
});
你说这是空的:
const map = new Map(Object.entries(array));
您是否尝试过自己添加值?
const map = new Map();
Object.entries(array).forEach(entry => {
map.set(entry[0], entry[1]);
});