jiajunchen vor 12 Stunden
Ursprung
Commit
c50ccbe274
1 geänderte Dateien mit 20 neuen und 10 gelöschten Zeilen
  1. 20
    10
      src/view/dati/checkTake/jieguo2.vue

+ 20
- 10
src/view/dati/checkTake/jieguo2.vue Datei anzeigen

@@ -116,7 +116,7 @@
116 116
 		proxy
117 117
 	} = getCurrentInstance()
118 118
 	const route = useRoute();
119
-  const userAnswers = ref({});
119
+  const userAnswers = reactive({});
120 120
 
121 121
   const questions = ref([]);
122 122
   //获取试卷
@@ -135,22 +135,32 @@ const confirmResult = () => {
135 135
   showResult.value=false
136 136
 }
137 137
   const getForm = async () => {
138
-    var url = '/sgsafe/ExamLine/query'
139
-    const query = ref({
140
-      headId: courseId
141
-    })
142
-    var param = {
143
-      params: JSON.stringify(query.value)
144
-    }
138
+    const url = '/sgsafe/ExamLine/query';
139
+    const query = {
140
+      headId: courseId.value // ✅ 不需要用 ref 包裹临时对象
141
+    };
142
+    const param = {
143
+      params: JSON.stringify(query)
144
+    };
145 145
     try {
146 146
       const res = await proxy.$axios.post(url, param);
147 147
       if (res.data.code === 0) {
148
-        questions.value = res.data.data
148
+        questions.value = res.data.data;
149
+
150
+        // ✅ 修复点2:清空 reactive 对象(不能用 .value)
151
+        for (const key in userAnswers) {
152
+          delete userAnswers[key];
153
+        }
154
+
155
+        // ✅ 修复点3:直接赋值,不要 .value!
156
+        res.data.data.forEach(q => {
157
+          userAnswers[q.id] = q.userAnswer; // 假设后端字段名为 userAnswer
158
+        });
149 159
       } else {
150 160
         console.log('操作失败!' + res.data.msg);
151 161
       }
152 162
     } catch (error) {
153
-      console.log('请求出错:', questions);
163
+      console.log('请求出错:', error);
154 164
     }
155 165
   };
156 166
 

Laden…
Abbrechen
Speichern