在最新的Visual Studio Code更新之后,我在Angular 8应用程序中写了很久以前的代码时遇到错误。
<div *ngFor="let product of productItems; let i = index">
<div *ngIf="i % 3 === 0 " class="card-deck mt-2">
<div class="card" *ngFor="let item of productItems.slice(i,i+3)">
...
第2行和第3行中的变量“ i”被标记为错误“期望数字类型ng(0)”。
目前我有点头绪,因为代码按预期工作,并且“ ng serve”和“ ng build”成功地服务和构建。
如果您使用的是语言服务,则可能会出现错误。有一个类似的现象问题。