如何解决找不到模块'@angular/router/src/utils/collection'或其相应的类型声明



如何解决错误:

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';

'forEach'是一个Javascript/Typescript方法,而不是angular的导入。它是数组原型的成员,因此你需要在你想操作的数组上调用它。

  1. 删除导入并按如下方式使用

    this.data。foreach(元素=比;{doNextTask ();});

如果你想循环作为键和索引,那么如下所示。

this.data.forEach(function callback(value, index) {
console.log(`${index}: ${value}`);
});

最新更新