Angular 영역 외부에서 탐색이 실행되었습니다. 'ngZone.run()'을 호출하는 것을 잊으셨나요?提示

문제 설명

폐쇄 함수에서 경로를 점프할 때 가끔 경로를 점프할 수 없고 Navigation Triggered Outside Angular zone 메시지가 표시되는 경우가 있습니다. 'ngZone.run()' 호출을 잊으셨나요?
폐쇄 힌트

해결책
import { Component, OnInit, NgZone } from '@angular/core';
export class * {
	 constructor(
            private route: Router,
            private ngZone: NgZone
      ) {}
      
       public navigate(commands: any[]): void {
            this.ngZone.run(() => this.route.navigate(commands)).then();
      }
}

클로저 함수를 호출하기 전에 that = this를 선언하고 that.navigate([*])를 사용하세요.

Supongo que te gusta

Origin blog.csdn.net/weixin_43909915/article/details/90289426
Recomendado
Clasificación