ngu-carousel :: ExpressionChangedAfterItHasBeenCheckedError:表达式在检查后发生了变化

问题描述 投票:0回答:1

我指的是这个例子https://stackblitz.com/edit/ngu-carousel-ng6?embed=1&file=src/app/app.component.html

但是在控制台中,我收到了这个错误

错误:ExpressionChangedAfterItHasBeenCheckedError:表达式在检查后已更改。上一个值:'ngForOf:'。当前值:'ngForOf:0,1,2,3,4,5'。

javascript angular typescript angular6
1个回答
0
投票

Here是解决您问题的方法

您可以使用ChangeDetectionStrategy

喜欢,

import { Component, ChangeDetectionStrategy } from '@angular/core';

    @Component({
      changeDetection: ChangeDetectionStrategy.OnPush,
      selector: 'my-app',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.css']
    })
© www.soinside.com 2019 - 2024. All rights reserved.