const Api = require('../net/Api'); cc.Class({ extends: cc.Component, properties: { questItem: { default: null, type: cc.Node, }, questWrap: { tooltip: '每日任务容器', default: null, type: cc.Node } }, onLoad () {}, init (quest) { this.quest = quest this.questItem.active = false Api.httpGet({ url: "/task/mainTask.do", data: {}, success: (res) => { let tasks = res.tasks for(let i = 0; i < tasks.length; i++) { let item = cc.instantiate(this.questItem) this.questWrap.addChild(item) item.active = true item.getComponent('QuestMainItem').init(this, tasks[i].list, tasks[i].sn, i) } } }) }, start () { }, // update (dt) {}, });