<style>
  .v_singleQuestion {
    width: 100%;
  }

</style>
<!--单选题查看-->
<template>
  <div class="v_singleQuestion">
    <table v-if="data&&data.QuestionContentObj&&data.QuestionContentObj.length>0">
      <tbody v-for="(item,index) in data.QuestionContentObj" :key="index">
        <tr>
          <td style="width:40px;text-align:center;">
            <template v-if="isOperate">
              <div class="Answer_List2" style="cursor:pointer;" @click="ChangeItem(item)"
                :class="{'Is_Answer':item.IsAnswer}">
                {{item.Name}}
              </div>
            </template>
            <template v-else>
              <div class="Answer_List2">
                {{item.Name}}
              </div>
            </template>
          </td>
          <td>
            <div class="InpDIV" style="border:0;" v-html="item.Content"></div>
          </td>
        </tr>
      </tbody>
      <tfoot v-if="isShowAnswer">
        <tr>
          <td colspan="2">正确答案：{{data.Answer}}</td>
        </tr>
        <tr>
          <td colspan="2">解析：<span v-html="data.AnswerParse"></span></td>
        </tr>
      </tfoot>
    </table>
  </div>
</template>
<script>
  export default {
    props: {
      questionObj: {
        type: Object,
      },
      //是否显示答案和解析
      isShowAnswer: {
        type: Boolean,
        default: false,
      },
      //是否可操作(PC端考试使用)
      isOperate: {
        type: Boolean,
        default: false,
      },
    },
    data() {
      return {
        data: this.questionObj,
      };
    },

    mounted() {},
    methods: {
      ChangeItem(item) {

        if (this.data.QuestionContentObj && this.data.QuestionContentObj.length > 0) {
          this.data.QuestionContentObj.forEach(item => {
            item.IsAnswer = false;
          })
        }
        item.IsAnswer = true;
        this.data.Answer = item.Name;
        console.log("this.data",this.data);
      },
    },
    watch: {
      isShowAnswer: {
        handler(newValue) {

        },
        deep: true
      },
    }
  };

</script>
