【发布时间】:2017-10-11 09:19:34
【问题描述】:
这是我的小提琴https://jsfiddle.net/y1s6pttt/,我在其中写下了我的代码
这适用于 Chrome 和 Mozilla,但不适用于 IE。问题在于箭头符号。箭头符号在 IE 中不起作用。
这是我在 IE 中遇到问题的代码部分。
months1 = data.reduce((p,c) => ~p.indexOf(c.months) ? p : p.concat(c.months),[]),
series = data.reduce((p,c) => { var f = p.find(f => f.name == c.project_title);
!!f ? f.data[months1.indexOf(c.months)] = c.amount*1
: p.push({name: c.project_title, id:c.project_title,
data: (new Array(months1.length)).fill(0).map((e,i) => i === months1.indexOf(c.months) ? c.amount*1 : e)});
return p;
},[]);
我在Babel中执行后将代码替换为下面的代码
months1 = data.reduce(function (p, c) {
return ~p.indexOf(c.months) ? p : p.concat(c.months);
}, []),
series = data.reduce(function (p, c) {
var f = p.find(function (f) {
return f.name == c.project_title;
});
!!f ? f.data[months1.indexOf(c.months)] = c.amount * 1 : p.push({ name: c.project_title, id: c.project_title,
data: new Array(months1.length).fill(0).map(function (e, i) {
return i === months1.indexOf(c.months) ? c.amount * 1 : e;
}) });
return p;
}, []);
即使用 Babel 代码替换后,我也收到错误 Object 不支持 jquery 中的属性或方法“find”
我需要用任何其他函数替换箭头符号以获得类似的输出。如何根据需要更改代码。
【问题讨论】:
-
什么版本的ie?
标签: javascript jquery internet-explorer arrow-functions