jianda.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <view v-if="question" class="phone-jianda-box">
  3. <view class="phone-shiti-question">
  4. <view class="question-num">{{question.onlyNum}}、</view>
  5. <!-- 题干区域 -->
  6. <rich-text :nodes="question.name"></rich-text>
  7. </view>
  8. <!-- 选项区域 -->
  9. <textarea class="jianda-textarea-box" placeholder="请输入内容" v-model="question.reply" />
  10. <view class="phone-question-answer-box">
  11. <view class="mb10">正确答案:</view>
  12. <view class="green-color">{{data.result}}</view>
  13. <view class="mb10">您的答案:</view>
  14. <view class="orange-color" v-if="data.reply">{{data.reply}}</view>
  15. <view class="btdf-row">本题得分:<text>{{data.score}}</text>分</view>
  16. <view class="dajx-row">答案解析:
  17. <rich-text :nodes="data.answer"></rich-text>
  18. </view>
  19. </view>
  20. </view>
  21. </template>
  22. <script setup>
  23. import {
  24. ref,
  25. reactive,
  26. watch
  27. } from 'vue';
  28. const props = defineProps({
  29. question: {
  30. type: Object,
  31. },
  32. showError: {
  33. type: Boolean,
  34. default: false
  35. }
  36. })
  37. const data = reactive({
  38. name: '', //题干数据
  39. score: '',
  40. result: '',
  41. reply: '',
  42. answer: '',
  43. contents: [], // 选项数据
  44. })
  45. watch(() => props.question, (val) => formatData(val), {
  46. immediate: true
  47. })
  48. function formatData(val) {
  49. if (val) {
  50. console.log('val',val);
  51. data.name = val.name;
  52. data.answer = val.answer;
  53. data.score = val.score;
  54. data.reply = val.reply;
  55. data.result = val.result;
  56. }
  57. }
  58. </script>