Vue uses iViewui components to circularly bind the v-model values of radio and checkbox components. How can I get the selected data and submit it?

        <Row type="flex" justify="start" v-for="(item,index) in questions" :key="item.id">
            <div class="question">
                <h5 class="question_title">{{index+1}}.{{item.title}}</h5>
                <RadioGroup v-if="item.questionType == """ v-model="answerInfo[index].singlechoice_default" vertical>
                    <Radio v-for="(it,i) in item.options" :label="it.id" :key="it.id" :checked.native="item.checked">
                      <span v-if="it.optionContent.indexOf("-sharpOTHER-sharp") == "-1"">{{it.optionContent}}</span>
                      <span v-else><Input v-if="it.optionContent.indexOf("-sharpOTHER-sharp") != "-1""></Input></span>
                    </Radio>
                </RadioGroup>
                <CheckboxGroup v-else-if="item.questionType == """ v-model="answerInfo[index].multichoice_default">
                    <Checkbox v-for="(it,i) in item.options" :label="it.id" :key="it.id" :checked.native="item.checked">
                      <span v-if="it.optionContent.indexOf("-sharpOTHER-sharp") == "-1"">{{it.optionContent}}</span>
                      <span v-else><Input v-if="it.optionContent.indexOf("-sharpOTHER-sharp") != "-1""></Input></span>
                    </Checkbox>
                </CheckboxGroup>
                <Input v-else v-model="item.input_value" type="textarea" :rows="6" placeholder="..."></Input>
            </div> 
        </Row>

  data() {
    return {
      questionId:"",
      questionDetail: {},
      questions: [],
      singlechoice_default: "",
      multichoice_default:[],
      answerInfo: [],
    };
  },

  created() {
    this.getQuestionDetail();
  },
    getQuestionDetail() {
      this.$get("course/list.json",{
          courseId: this.$route.query.id
        },response => {
          this.questionDetail = response.data[0];
          this.questionId = response.data[0].questionId;          
          this.getDetail(this.questionId);
        }
      );
    },
    getDetail(questionid) {
      this.$get("info/list.json",{
          questionid: questionid
        },response => {         
          response.data.forEach((item,index,arr) => {
            if (item.questionType === "") {
                item.multichoice_default = this.multichoice_default;                
            } else if (item.questionType === "") {
                item.singlechoice_default = this.singlechoice_default;
            } else {
              
            }
          });
          this.answerInfo = response.data;           
          this.questions = response.data;
        }
      );
    },
  }


vue novice, ask for your advice.

how do I get the selected data and submit it?

Mar.28,2021

change event Let item come out
or look at the document to provide no event


< RadioGroup @ on-change= "handleChange ()" vmurifs = "item.questionType = = 'single choice'" vMube model = "promoerInfo [index] .singlechoice _ default" vertical >
< / RadioGroup >

handleChange (val) in method to get val


you can use on-change upstairs or listen to answerInfo directly in watch


seems to loop through answerInfo to get singlechoice_default and multichoice_default .

hehe, how humiliating, cover your face-_ | |

Menu