const {ccclass, property} = cc._decorator; @ccclass export default class CommonTextTips extends cc.Component { @property(cc.Node) contentNode: cc.Node = null; @property(cc.Node) contentStr: cc.Node = null; onLoad () { } start () { } initView(contentStr, time, isRich){ if(isRich){ this.contentStr.active = false this.contentNode.getChildByName('contentStr2').active = true let str2Node = this.contentNode.getChildByName('contentStr2') str2Node.getComponent(cc.RichText).string = contentStr cc.tween(this.contentNode).delay(time).to(0.5, { y: 555, opacity: 0 }).call(() => { this.node.removeFromParent() }).start(); }else{ this.contentStr.getComponent(cc.Label).string = contentStr cc.tween(this.contentNode).delay(time).to(0.5, { y: 555, opacity: 0 }).call(() => { this.node.removeFromParent() }).start(); } } }