const { ccclass, property } = cc._decorator; @ccclass export default class TurnableItem extends cc.Component { @property(cc.Sprite) icon: cc.Sprite = null; @property(cc.Label) lbl_name: cc.Label = null; public async initData(type, id:number) { this.icon.spriteFrame = await mk.loader.load('module/turnable/texture/hb' + type, cc.SpriteFrame); this.lbl_name.string = type == 1 ? "少量红包" : type == 2 ? "中量红包" : type == 3 ? "大量红包" : "6元现金" ; let outline = this.lbl_name.getComponent(cc.LabelOutline); if(outline) { if(id%2==0) { outline.color = cc.color(217, 88, 9, 255); }else outline.color = cc.color(95, 159, 12, 255); } } }