1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677 |
- <template>
- <view v-if="question" class="phone-tiankong-box">
- <view class="phone-shiti-question">
- <view class="question-num">{{question.onlyNum}}、</view>
- <!-- 题干区域 -->
- <rich-text :nodes="question.name"></rich-text>
- </view>
- <!-- 选项区域 -->
- <view v-for="(item,index) in question.reply" class="tiankong-option-box" :key="index"
- :class="formatClass(index)">
- <text class="option-question">填空{{index+1}}:</text>
- <input type="text" v-model="question.reply[index]" class="option-question-text"
- :placeholder="`请输入填空${index+1}答案`">
- </view>
- <view class="phone-question-answer-box">
- <view class="phone-line-title">答案解析</view>
- <view class="btdf-row">本题得分:<text>{{data.score}}</text>分</view>
- <view class="zqda-row">正确答案:
- <view v-for="(item,index) in data.result">{{`填空${index+1}`}} : {{item}}</view>
- </view>
- <view class="ndda-row">您的答案:
- <view v-for="(item,index) in data.reply"> {{`填空${index+1}`}}: {{item}}</view>
- </view>
- <view class="dajx-row">答案解析:
- <rich-text :nodes="data.answer"></rich-text>
- </view>
- </view>
- </view>
- </template>
- <script setup>
- import {
- ref,
- reactive,
- watch
- } from 'vue';
- const data = reactive({
- name: '', //题干数据
- score: '',
- result: '',
- reply: '',
- answer: '',
- contents: [], // 选项数据
- })
- const props = defineProps({
- question: {
- type: Object,
- },
- showError: {
- type: Boolean,
- default: false
- }
- })
- watch(() => props.question, (val) => formatData(val), {
- immediate: true
- })
- function formatData(val) {
- data.reply = val.reply || [];
- data.result = val.result || [];
- data.answer = val.answer;
-
- }
- function formatClass(index) {
- if (props.showError) {
- return {
- active_right: props.question.result[index].some(item => item == props.question.reply[index] ? props
- .question.reply[index].trim() : ''),
- showError: !props.question.result[index].some(item => item == props.question.reply[index] ? props.question
- .reply[index].trim() : '')
- }
- }
- }
- </script>
|