我如何解决错误:
src/app/metronic/orderByLocation/locationsByOneOrder/locationsByOneOrder.component.ts:7:25 - error TS2307: Cannot find module '@angular/router/src/utils/collection' or its corresponding type declarations.m
7 import { forEach } from '@angular/router/src/utils/collection';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error: src/app/metronic/orderByLocation/update-location/subpoena-options/subpoena-options.component.ts:5:25 - error TS2307: Cannot find module '@angular/router/src/utils/collection' or its corresponding type declarations.
5 import { forEach } from '@angular/router/src/utils/collection';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error: src/app/metronic/orderByLocation/update-location/update-location.component.ts:6:25 - error TS2307: Cannot find module '@angular/router/src/utils/collection' or its corresponding type declarations.
6 import { forEach } from '@angular/router/src/utils/collection';
答案 0 :(得分:0)
'forEach' 是一个 Javascript / Typescript 方法,而不是一个角度导入。它是数组原型的成员,因此需要在要操作的数组上调用它。
删除导入并使用如下。
this.data.foreach(元素 => { doNextTask(); });
如果您想作为键和索引循环,则如下所示。
this.data.forEach(function callback(value, index) {
console.log(`${index}: ${value}`);
});