cc.Class({ extends: cc.Component, properties: { packItemPrefab: cc.Prefab, pageLayout: cc.Layout, }, // LIFE-CYCLE CALLBACKS: onLoad () { }, init() { for (var i = 0; i < 20; i++) { let item = cc.instantiate(this.packItemPrefab); this.pageLayout.node.addChild(item); } }, onDisable () { for (let child of this.pageLayout.node.children) { if (cc.isValid(child)) { child.destroy(); } } }, start () { }, // update (dt) {}, });