<template>
  <div>
    <div class="exersices-content">
      <IconText :text="'题目'" :color="'#2d8cf0'" :icon="'ios-create'" style="margin-bottom:15px;"></IconText>
      <div>
        <div ref="editor" style="text-align:left"></div>
      </div>
    </div>
    <div class="exersices-option">
      <IconText :text="'选项'" :color="'#FF871C'" :icon="'md-reorder'"></IconText>
      <RadioGroup v-model="trueAnswer" type="button" size="large">
        <Radio label="正确"></Radio>
        <Radio label="错误"></Radio>
      </RadioGroup>
    </div>
  </div>
</template>
<script>
  import E from 'wangeditor'
  import IconText from '@/components/evaluation/IconText.vue'
  export default {
    components: {
      IconText
    },
    props: ['editInfo'],
    data() {
      return {
        trueAnswer: "正确",
        defaultConfig: {
          uploadImgServer: '/api/file/uploadWangEditor', //图片上传地址
          showLinkImg: false, //是否展示网络图片链接上传
          uploadFileName: 'files', //上传图片后台获取的文件名
        },
        stemContent: "",
        stemEditor:null
      }
    },
    methods: {
      
    },
    mounted() {
      let stemEditor = new E(this.$refs.editor);
      stemEditor.customConfig = this.defaultConfig;
      stemEditor.customConfig.onchange = (html) => {
        this.stemContent = html;
      }
      stemEditor.create();
      this.stemEditor = stemEditor;

       //判断是否为编辑状态
      if (Object.keys(this.editInfo).length > 0) {
        this.stemEditor.txt.html(this.editInfo.question);
        this.stemContent = this.editInfo.question;
        this.trueAnswer = this.editInfo.answer[0] == 'A' ? '正确' :'错误';
      }

    }
  }
</script>

