import { _decorator, Component, instantiate, Node } from 'cc';
import { att_question_select } from '../../../data/data';
import { btn_question_item } from './btn_question_item';
const { ccclass, property } = _decorator;

@ccclass('question_select')
export class question_select extends Component {
    private m_data:att_question_select = null;
    @property(Node) btn_question:Node = null;
    @property(Node) content:Node = null;
    public initView(data:att_question_select){
        this.m_data = data;
        this.updateView(this.m_data)
    }

    public updateView(data:att_question_select){
        this.m_data = data;
        this.content.destroyAllChildren();
        this.content.removeAllChildren();
        for (let index = 0; index < this.m_data.btn_question_list.length; index++) {
            const element = this.m_data.btn_question_list[index];
            let item = instantiate(this.btn_question)
            item.active = true;
            item.parent = this.content;
            item.getComponent(btn_question_item).initView(element,index)
            this.m_data.btn_question_list[index] =  item.getComponent(btn_question_item).getData()
        }
    }
}


