tiankong.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <template>
  2. <view v-if="question" class="phone-tiankong-box">
  3. <view>{{question.onlyNum}}、</view>
  4. <!-- 题干区域 -->
  5. <rich-text :nodes="question.name" class="phone-shiti-question"></rich-text>
  6. <!-- 选项区域 -->
  7. <view v-for="(item,index) in question.reply" class="tiankong-option-box" :key="index" :class="formatClass(index)">
  8. <text>填空{{index+1}}:</text>
  9. <input type="text" v-model="question.reply[index]" class="tk-answer-text" :placeholder="`请输入填空${index+1}答案`">
  10. </view>
  11. </view>
  12. </template>
  13. <script setup>
  14. const props = defineProps({
  15. question: {
  16. type: Object,
  17. },
  18. showError: {
  19. type: Boolean,
  20. default: false
  21. }
  22. })
  23. function formatClass(index) {
  24. if (props.showError) {
  25. return {
  26. active_right: props.question.result[index].some(item => item == props.question.reply[index]?props.question.reply[index].trim(): ''),
  27. showError: !props.question.result[index].some(item => item == props.question.reply[index]?props.question.reply[index].trim(): '')
  28. }
  29. }
  30. }
  31. </script>
  32. <style lang="scss" scoped>
  33. .tiankong-option-box {
  34. margin-top: 10px;
  35. }
  36. .tk-answer-text {
  37. border: 1px solid #ccc;
  38. padding: 5px;
  39. }
  40. </style>