#Cocos Creator# 错误 1510:Illegal target which doesn't have uuid or instanceId.
遇到一个奇怪的错误,不要慌。

遇到这个错误,不要慌,检查一下自定义组件类是否定义了属性 _id,像这样子:
@property(cc.Label) txtPrice:cc.Label = null;// @property(cc.pr @property(cc.Toggle) tglSelect:cc.Toggle = null; @property(cc.SpriteFrame) defaultSpriteFrame:cc.SpriteFrame = null; _shopItemId:number = 0; _id:number = 0; // <=== 罪魁祸首
如果是,那么把_id属性改成别的名字就ok了。
不要问为什么没有提示重复定义什么的,嗯。
以后定义属性的时候小心一点,太通用的名字很可能以后被系统用了, 比如name。
平时可以研究一下以下几个类:
cc.Component
文档:https://docs.cocos.com/creator/api/zh/classes/Component.html
代码:https://github.com/cocos-creator/engine/blob/915ccf4e6e273f9003c14560ab1e48f9fa090132/cocos2d/core/components/CCComponent.js