试了很多种方法, 试图获得button的label组件, 再设置string属性, 但是获取的label组件都是cc.Node类型, 无法设置string属性.
this.node.getChildByName("Label").getComponent(cc.Label).string=123;
Label不是组件,是Button的Child
2赞
原来如此,多谢。这块明白点了
另外,我看属性面板,label也是button的组件,为什么不能用this.node.getComponent(cc.Label).string=“xxx”;来设置?
嗯…为什么会有label组件…

我觉得没有任何必要,除非button和label有什么特殊的关联,目前看来也不是什么特殊的关联,不像scrollView与scrollViewBar的关系。。