_components.length 为null

  • Creator 版本:1.9.3

  • 目标平台: 微信小游戏

  • 详细报错信息,包含调用堆栈:
    TypeError
    null is not an object (evaluating ‘t._components.length’)

  • 重现方式:未知

  • 手机浏览器 微信浏览器

  • 出现概率:40% 左右

  • 额外线索:调用 getComponent 引擎里 TypeError
    null is not an object (evaluating ‘t._components.length’)
    报错

请问LZ有解决这个问题么?? 我也触发了这个报错信息。

我追寻了 调用栈 是在 base-node.js 里的 findComponent 和 findComponents 这两个方法里 的 for循环里 报出来的, 我占时用 判断来解决 ,从流程来看 是 getComponent这个 方法触发的,但是不知道 什么情况下,会出现_components 为null 的 我个人感觉是 可能节点将要 销毁时 可能刚好执行了代码

我这边的调用堆栈则是在设置 node 的 active 属性的时候,也是会去遍历 Component。估计也还是节点将要销毁时执行了。

试着用cc.isValid(node); 判断一下

恩恩,已经用该方法对设置加上保护了。