【发布时间】:2017-11-14 02:33:51
【问题描述】:
下面是具有根据我的业务需要更改行、列的逻辑的代码。当我保留此代码时,在我的 Angular2 ts 代码中,我得到 Supplied parameters do not match any signature of call target error at .forEach(...
var data = [{ Id: "a", ColumnLocation: "0", RowLocation: "0" }, { Id: "b", ColumnLocation: "0", RowLocation: "1" }, { Id: "4", ColumnLocation: "0", RowLocation: "3" }, { Id: "c", ColumnLocation: "1", RowLocation: "0" }, { Id: "d", ColumnLocation: "1", RowLocation: "2" }, { Id: "e", ColumnLocation: "2", RowLocation: "0" }, { Id: "e", ColumnLocation: "2", RowLocation: "2" }];
data.forEach(function (col, row) {
return function (o) {
if (col !== o.ColumnLocation) {
col = o.ColumnLocation;
row = 0;
}
if (+o.RowLocation !== row) {
o.RowLocation = row.toString();
}
row++;
}
}());
【问题讨论】:
-
data在哪里?你的意思是array.forEach? -
data是什么?你使用array编辑:呸。弗兰克打败了我 :) -
不是数组,是数据。道歉..
-
好的,所以现在你传递给
forEach的函数实际上会传入不同的东西(数组中的元素、索引和数组)。查看developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/…。您能否更新您的问题以考虑到这一点? -
是的。我已经更新了问题。
标签: javascript angular typescript