const DrawApi = require("../net/DrawApi"); cc.Class({ extends: cc.Component, properties: { item: cc.Node, moneyTileRichText: cc.RichText, content: cc.Node, }, // LIFE-CYCLE CALLBACKS: onLoad () { /// 获取红包记录数据 this.moneyTileRichText.string = `余额:¥9.12`; DrawApi.getDrawHbs((respondData) => { let reds = respondData.list; /// 如果有红包记录 if (reds != undefined || reds.length > 0) { for (let i = 0; i < reds.length; ++ i) { let contentItem = cc.instantiate(this.item); this.content.addChild(contentItem); contentItem.getComponent('DrawRedRecordItem').init(reds[i]); } } }, (err, code) => { console.log(err, code); }) }, start () { }, // update (dt) {}, });