关于2.0.9的按钮组件

我新建一个Toggle组件,然后将Target叉掉:

然后再拖回去还原:

然后控制台输出报错:
> Failed to set property New Toggle to [object Object] at target, TypeError: Cannot read property ‘off’ of null

查看了Toggle的父类CCButton中关于target的属性定义:

比前几个版本多了:

**    我打了下断点,这个oldValue是null的**
**    所以我觉得这是开发者在修改某些问题时新写的bug!**

别沉啊

恭喜玩家发现: 一个新写的bug,
这个bug 是新旧按钮结构不一样引发的问题…

这个bug,升级引擎肯定就有问题了啊,怎么快速兼容啊??????????

这个bug我们会修复一下,新旧版本的button空间结构是有变化,但这个bug不会导致旧版的button结构放到新版本中就无法使用.
可以在CCButton.js中改一下_unregisterTargetEvent这个方法即可

    _unregisterTargetEvent (target) {
        if (target === null) {
            return;
        }
        if (CC_EDITOR) {
            target.off('spriteframe-changed', this._onTargetSpriteFrameChanged, this);
            target.off(cc.Node.EventType.COLOR_CHANGED, this._onTargetColorChanged, this);
        }
        target.off(cc.Node.EventType.SCALE_CHANGED, this._onTargetScaleChanged, this);
    },

已修复,谢谢反馈 https://github.com/cocos-creator/engine/pull/4252