我指的是这个例子https://stackblitz.com/edit/ngu-carousel-ng6?embed=1&file=src/app/app.component.html
但是在控制台中,我收到了这个错误
错误:ExpressionChangedAfterItHasBeenCheckedError:表达式在检查后已更改。上一个值:'ngForOf:'。当前值:'ngForOf:0,1,2,3,4,5'。
Here是解决您问题的方法
您可以使用ChangeDetectionStrategy
喜欢,
import { Component, ChangeDetectionStrategy } from '@angular/core';
@Component({
changeDetection: ChangeDetectionStrategy.OnPush,
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})