问题
Unfortunately I have to support IE11.
I create my map with this code (polyfill for .entries already used):
const map = new Map(Object.entries(array));
but because of IE11 not supporting the iterable constructor the Map is empty.
I couldn't find a polyfill or anything else for this. Does anyone have an easy way of fixing this?
Afterwards I use the map
like this:
map.forEach((maps: ITopoInterface[], key: string) => {
maps.findIndex((t: ITopoInterface) => {
//do stuff
});
});
回答1:
You say this is empty:
const map = new Map(Object.entries(array));
Have you tried just adding the values yourself?
const map = new Map();
Object.entries(array).forEach(entry => {
map.set(entry[0], entry[1]);
});
来源:https://stackoverflow.com/questions/59375015/mapiterable-alternative-for-ie-11