_inheritsLoose(subClass, superClass)

  • Creator 版本:

  • 目标平台:

  • 重现方式:

  • 首个报错:

  • 之前哪个版本是正常的:

  • 手机型号:

  • 手机浏览器:

  • 编辑器操作系统:

  • 重现概率:

自定义两个类 ANode Actor 设置Actor 继承ANode ANode没有父类
@ccclass(‘ANode’)
export class ANode {
public node: Node = null!;
constructor(…params: any) {
this.node = new Node();
}
}

@ccclass(‘Actor’)
export class Actor extends ANode {
constructor(…params: any) {
super(params);
}
}

发布为 web-mobile

var ccclass = _decorator.ccclass;
var Actor = exports(‘Actor’, (_dec = ccclass(‘Actor’), _dec(_class = (_temp = /#PURE/function (_ANode) {
:10095 _inheritsLoose(Actor, _ANode);

    function Actor() {
      var _this;

执行些函数时 superClass 为undefined
function _inheritsLoose(subClass, superClass) {
:52 subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;

    _setPrototypeOf(subClass, superClass);
  }

求原因,因很多类对ANode进行继承 问题都同上 一直查不出原因来
执行_inheritsLoose函数 superClass为空,然后不报错了

TypeError: Cannot read property ‘prototype’ of undefined
at _inheritsLoose (bundle.js:52)
at index.js:10095
at Object.execute (index.js:10223)
at doExec (system.bundle.js:467)
at postOrderExec (system.bundle.js:463)
at system.bundle.js:449
at Array.forEach ()
at postOrderExec (system.bundle.js:447)
at system.bundle.js:449
at Array.forEach ()

可能循环引用了

我的也出现了,请问是怎么解决的?

是继承的循环引用,还是import的循环引用呢?

这个要怎么解决?

麻烦问下,有解决吗?

的确循环引用导致

你好, 请问这个问题解决了没

兄弟怎么处理啊,我这也是继承的循环引用出的问题

不难处理,用调试模式打包到微信开发工具,报错的地方断点,设置条件,好像是superClass == null作为条件。然后跑的时候断到,去看subClass类名,就知道这个类需要改动了。解除引用,解除继承等可能的问题。实际上建议官方合理报错,省了大家时间