如何解决角" 10 $摘要()迭代达到"错误 [英] How to Troubleshoot Angular "10 $digest() iterations reached" Error
问题描述
10 $digest() iterations reached. Aborting!
有很多的,在过去的5次迭代解雇看守:意义上的配套文本等等,但很多这样的文字是各种功能的Javascript code。对于诊断这个问题拇指有规则吗?难道总是可以减轻,还是有应用足够复杂,这个问题应该只是一个警告来处理问题吗?
There is a lot of supporting text in the sense of "Watchers fired in the last 5 iterations: ", etc., but a lot of this text is Javascript code from various functions. Are there rules of thumb for diagnosing this problem? Is it a problem that can ALWAYS be mitigated, or are there applications complex enough that this issue should be treated as just a warning?
推荐答案
作为法师说,你要么返回不同的(不完全相同)对象上的每个 $消化
周期,或者你正在改变数据的次数太多了。
as Ven said, you are either returning different (not identical) objects on each $digest
cycle, or you are altering the data too many times.
最快的解决方案,以找出您的应用的一部分,是造成这种行为是:
- 删除所有可疑的HTML - 基本上都是从模板中删除所有的HTML,并检查是否有任何警告
- 如果没有警告 - 你取出的HTML添加小部件检查问题又回来了
- 重复步骤2,直到你得到一个警告 - 你会找出其中你的HTML的一部分,负责问题
- 进一步调查 - 部分从第3步是负责要么变异的
$范围
的对象或者是在每区选出不相同的物体$摘要
周期 - 第1步后,如果仍然有
$消化
反复警告,比你可能做的事情很可疑。重复父模板/范围/控制器相同的步骤
- remove all suspicious HTML - basically remove all your html from the template, and check if there are no warnings
- if there are no warnings - add small parts of the html you removed and check if the problem is back
- repeat step 2 until you get a warning - you will figure out which part of your html is responsible for the problem
- investigate further - the part from step 3 is responsible for either mutating the objects on the
$scope
or is returning non-identical objects on each$digest
cycle. - if you still have
$digest
iteration warnings after step 1, than you are probably doing something very suspicious. Repeat the same steps for parent template/scope/controller
您也想确保你不改变你的自定义过滤器的输入
请记住,在JavaScript中有没有表现得像你特定类型的对象通常期望:
Keep in mind, that in JavaScript there are specific types of objects that don't behave like you would normally expect:
new Boolean(true) === new Boolean(true) // false
new Date(0) == new Date(0) // false
new String('a') == new String('a') // false
new Number(1) == new Number(1) // false
[] == [] // false
new Array == new Array // false
({})==({}) // false
这篇关于如何解决角" 10 $摘要()迭代达到"错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!