jiajunchen 10 godzin temu
rodzic
commit
c50ccbe274
1 zmienionych plików z 20 dodań i 10 usunięć
  1. 20
    10
      src/view/dati/checkTake/jieguo2.vue

+ 20
- 10
src/view/dati/checkTake/jieguo2.vue Wyświetl plik

116
 		proxy
116
 		proxy
117
 	} = getCurrentInstance()
117
 	} = getCurrentInstance()
118
 	const route = useRoute();
118
 	const route = useRoute();
119
-  const userAnswers = ref({});
119
+  const userAnswers = reactive({});
120
 
120
 
121
   const questions = ref([]);
121
   const questions = ref([]);
122
   //获取试卷
122
   //获取试卷
135
   showResult.value=false
135
   showResult.value=false
136
 }
136
 }
137
   const getForm = async () => {
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
     try {
145
     try {
146
       const res = await proxy.$axios.post(url, param);
146
       const res = await proxy.$axios.post(url, param);
147
       if (res.data.code === 0) {
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
       } else {
159
       } else {
150
         console.log('操作失败!' + res.data.msg);
160
         console.log('操作失败!' + res.data.msg);
151
       }
161
       }
152
     } catch (error) {
162
     } catch (error) {
153
-      console.log('请求出错:', questions);
163
+      console.log('请求出错:', error);
154
     }
164
     }
155
   };
165
   };
156
 
166
 

Ładowanie…
Anuluj
Zapisz