cc.Class({ initRoot (rootNode) { this.rootNode = rootNode; this.views = []; this.curViewType = null; this.cells = []; return this; }, addViewData(viewType) { self.cells = [] this.views.push({type:viewType, view:null, initing:false}) }, createOrShowView(type, parent) { let viewData = this.views[type] for (let vd of this.views) { if (vd.view == null) { continue } vd.view.active = false; } if (viewData.initing) { return } if (viewData.view != null) { viewData.view.active = true; return } viewData.initing = true let self = this this.rootNode.createComponent(viewData.type, parent, null, function(node, status) { if (status != 'ok') { return } viewData.view = node viewData.initing = false node.active = self.curViewType == type self.cells.push(node) }) } })