Chrome DevTools 中的 NgZone 超时警告尽管超时 运行 在区域外
NgZone timeout warnings in Chrome DevTools despite timeouts running outside the zone
在 Chrome DevTools
中仍然收到警告是否正常
[Violation] 'setTimeout' handler took 103ms zone.js:1894
即使你 运行 所有超时都在 ngzone 之外?我是这样做的:
this.zone.runOutsideAngular(() => {
this._timeout = setTimeout(() => {
// ...
});
});
并清除现有超时 onDestroy (Angular)
setTimeout
在 Angular 之外运行并不意味着它在区域之外运行。
如the reference所述,
Executes the fn function synchronously in Angular's parent zone and returns value returned by the function.
Running functions via runOutsideAngular allows you to escape Angular's zone and do work that doesn't trigger Angular change-detection or is subject to Angular's error handling.
所以预计setTimeout
仍然在一个区域内运行。
在 Chrome DevTools
中仍然收到警告是否正常[Violation] 'setTimeout' handler took 103ms zone.js:1894
即使你 运行 所有超时都在 ngzone 之外?我是这样做的:
this.zone.runOutsideAngular(() => {
this._timeout = setTimeout(() => {
// ...
});
});
并清除现有超时 onDestroy (Angular)
setTimeout
在 Angular 之外运行并不意味着它在区域之外运行。
如the reference所述,
Executes the fn function synchronously in Angular's parent zone and returns value returned by the function.
Running functions via runOutsideAngular allows you to escape Angular's zone and do work that doesn't trigger Angular change-detection or is subject to Angular's error handling.
所以预计setTimeout
仍然在一个区域内运行。