【问题标题】:How to assign Object assign and map function together in IE 11如何在 IE 11 中同时分配对象分配和映射功能
【发布时间】:2021-11-16 17:02:43
【问题描述】:

我的示例代码在 Chrome 中运行良好,但由于 Object.assign 方法和 => 符号,IE11 出现问题。

下面是我的代码,我不知道如何为 IE11 设计它:

 let dictionary = Object.assign({}, ...tempGroups[tempKey].map((x) => ({ [x.ID]: x.Value })));

感谢您的帮助。

【问题讨论】:

标签: javascript internet-explorer internet-explorer-11


【解决方案1】:

Object.assign 不支持 IE-11。尝试使用循环复制它,因为无论如何您都在使用地图。

除了arrow functions,您还可以使用普通函数。

let dictionary = {};
tempGroups[tempKey].forEach(
function(x) {
 dictionary[x.ID] =  x.Value; 
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-04
    相关资源
    最近更新 更多