父子孙三类,子类继承父类,孙类继承子类时,运行报错

  • 详细报错信息,包含调用堆栈:
    The Web Audio autoplay policy will be re-enabled in Chrome 70 (October 2018). Please check that your website is compatible with it. https://goo.gl/7K7WLu
    cocos2d-js-for-preview.js:29015
    Cocos Creator v2.1.0
    cocos2d-js-for-preview.js:8399
    TypeError: Object prototype may only be an Object or null: undefined
    cocos2d-js-for-preview.js:81617
    at setPrototypeOf ()
    at 327.window.__extends (http://localhost:7456/app/engine/bin/cocos2d-js-for-preview.js:81617:7)
    at c:\Users\Administrator\Documents\GameplayFramework-master\assets\scripts\Character\Appear\Player\AppearIdlePlayer.ts:4:39
    at __define (c:\Users\Administrator\Documents\GameplayFramework-master\assets\scripts\Character\Appear\Player\AppearIdlePlayer.ts:4:39)
    at Object.func (c:\Users\Administrator\Documents\GameplayFramework-master\temp\quick-scripts\assets\scripts\Character\Appear\Player\AppearIdlePlayer.js:48:18)
    at Object.cc.require (http://localhost:7456/app/editor/static/preview-templates/modular.js:64:19)
    at __require (c:\Users\Administrator\Documents\GameplayFramework-master\temp\quick-scripts\assets\scripts\Character\Character\CharacterPlayer.js:1:284)
    at __define (c:\Users\Administrator\Documents\GameplayFramework-master\assets\scripts\Character\Character\CharacterPlayer.ts:7:1)
    at Object.func (c:\Users\Administrator\Documents\GameplayFramework-master\temp\quick-scripts\assets\scripts\Character\Character\CharacterPlayer.js:60:18)
    at Object.cc.require (http://localhost:7456/app/editor/static/preview-templates/modular.js:64:19)

  • 重现方式:demo直接运行

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

  • 手机型号 :

  • 手机浏览器 :

  • 编辑器操作系统 :windows

  • 编辑器之前是否有其它报错 :

NewProject.zip (933.8 KB)

自己写了一个简单的demo试了一下,按照你说的父子孙三类继承下来并不会报错。Test.zip (588.1 KB)

看了一下你发出来的工程,是ts文件循环import的问题。注释掉就一切正常了


感谢 我这就试试去

之所以循环import,是因为在AppearIdle里要做一个this.owner instanceof CharacterPlayer的类型判断,ChracterPlayer这个类型,导致导入了CharacterPlayer。
看到了一个TS的局限性了。
目前想到的解决方案是在CharacterPlayer的基类Character里加类型变量直接判断。