0

angular アプリで chart.js を使用し、API エンドポイントからのデータを使用してグラフを描画しています。

ngOnInit(): void {
this._route.params.subscribe(p => {
  let id: number = +this._route.snapshot.params["id"];
  this.busy = this._awpsService
  .getOutcomeItem("years", id).subscribe(data => {
      this.years = data;
      this.selYear = this.years[0];

      this.ngZone.onMicrotaskEmpty.first.subscribe(() => {
        $("#year").selectpicker();
        $(window).resize();
      });

      this.getProjectItems(id);

    });
});
}

上記のコードは angular 4 で完全に正常に動作していましたが、angular 7 にアップグレードした後、コードを次のように変更する必要がありました。

this.ngZone.onMicrotaskEmpty.subscribe(() => {
            $("#year").selectpicker();
            $(window).resize();
});

.firstangular 7でなくなったためです。これにより、CPU使用率が増加し、アプリがクラッシュしました。はngZone.onMicrotaskEmpty.first私のアプリで広く使用されていますが、変更検出を適切に処理する方法がわかりません。この方法も試しました

this.ngZone.onMicrotaskEmpty.subscribe({
        next: () => {
          this.ngZone.run(() => {
            $('#year').selectpicker();
            $(window).resize();
          });
        }
});

しかし運がない。誰でもこれで私を助けることができますか?ありがとう

4

0 に答える 0