Переглянути джерело

对于某些图片套题,会导致高度计算错误,需多次nextTick

Michael Wang 5 роки тому
батько
коміт
a99ab2fbca
1 змінених файлів з 15 додано та 12 видалено
  1. 15 12
      src/features/OnlineExam/Examing/QuestionView.vue

+ 15 - 12
src/features/OnlineExam/Examing/QuestionView.vue

@@ -212,20 +212,23 @@ export default {
       this.question =
         question.questionUnitList[currentExamQuestion.subNumber - 1];
 
+      // 对于某些图片套题,会导致高度计算错误,需多次nextTick
       this.$nextTick(() => {
-        // 从非套题进入套题时,会根据套题的内容动态调整套题的默认高度
-        const parentQuestion = document.getElementsByClassName(
-          "parent-question"
-        )[0];
-        if (parentQuestion) {
-          this.parentPaneHeight =
-            5 +
-            (100 * parentQuestion.clientHeight) /
-              (document.body.clientHeight - 160);
-          if (this.parentPaneHeight > 60) {
-            this.parentPaneHeight = 60;
+        this.$nextTick(() => {
+          // 从非套题进入套题时,会根据套题的内容动态调整套题的默认高度
+          const parentQuestion = document.getElementsByClassName(
+            "parent-question"
+          )[0];
+          if (parentQuestion) {
+            this.parentPaneHeight =
+              5 +
+              (100 * parentQuestion.clientHeight) /
+                (document.body.clientHeight - 160);
+            if (this.parentPaneHeight > 60) {
+              this.parentPaneHeight = 60;
+            }
           }
-        }
+        });
       });
       {
         // cache next question content