Parcourir la source

套题切换题目,音频播放不停止。

Michael Wang il y a 5 ans
Parent
commit
7522334446
1 fichiers modifiés avec 22 ajouts et 5 suppressions
  1. 22 5
      src/features/OnlineExam/Examing/QuestionView.vue

+ 22 - 5
src/features/OnlineExam/Examing/QuestionView.vue

@@ -82,8 +82,8 @@ export default {
     ...mapState(["examQuestionList"]),
   },
   watch: {
-    $route: function() {
-      this.updateQuestion();
+    $route: function(to, from) {
+      this.updateQuestion(to, from);
     },
   },
   created() {
@@ -92,11 +92,25 @@ export default {
   mounted() {},
   methods: {
     ...mapMutations(["updateExamQuestion"]),
-    async updateQuestion() {
+    async updateQuestion(to, from) {
       const currentExamQuestion = this.examQuestion; // 避免以后执行时,this.examQuestion换掉了
       const examRecordDataId = this.$route.params.examRecordDataId;
-      this.parentQuestionBody = null;
-      this.question = null;
+      // if(this.examQuestion.questionId) {
+      //   this.parentQuestionBody = null;
+      //         this.question = null;
+      // }
+      // console.log(from, to);
+      if (from && to) {
+        const orderFrom = from.params.order - 1;
+        const toFrom = to.params.order - 1;
+        if (
+          this.examQuestionList[orderFrom].questionId !==
+          this.examQuestionList[toFrom].questionId
+        ) {
+          this.parentQuestionBody = null;
+          this.question = null;
+        }
+      }
       let qContentRes = null;
       try {
         qContentRes = await this.$http.get(
@@ -111,7 +125,10 @@ export default {
           console.log(
             "QuestionView: 如果网络异常,又离开本页面后,不再后续处理此请求 "
           );
+          return;
         }
+        this.parentQuestionBody = null;
+        this.question = null;
         return;
       }