Parcourir la source

417math异常修改

tangjunhao il y a 4 mois
Parent
commit
119d7963cb
2 fichiers modifiés avec 18 ajouts et 4 suppressions
  1. 17 3
      src/components/PythonEditor/index.vue
  2. 1 1
      src/views/titlecomponent/MathFunc.vue

+ 17 - 3
src/components/PythonEditor/index.vue

@@ -26,10 +26,24 @@ watch(
   () => getCurrentValue(),
   (newValue) => {
     const editorVal = getEditorValue();
-    if (editor.value && newValue !== editorVal) {
-      isUpdatingFromParent = true; // 开锁,标记是外部更新
+    const normalize = (s) => (s || '').trim();
+
+    if (editor.value && normalize(newValue) !== normalize(editorVal)) {
+      console.log('外部更新编辑器内容', newValue);
+      console.log('当前编辑器内容', editorVal);
+
+      isUpdatingFromParent = true;
+
+      // 设置值
       editor.value.setValue(newValue || '');
-      isUpdatingFromParent = false;
+
+      // 等当前宏任务结束后再解除锁
+      queueMicrotask(() => {
+        isUpdatingFromParent = false;
+        console.log('编辑器内容已更新', editor.value.getValue());
+      });
+    } else {
+      console.log('内容相同,跳过更新');
     }
   }
 );

+ 1 - 1
src/views/titlecomponent/MathFunc.vue

@@ -38,7 +38,7 @@
         </el-table>
     </div>
 
-    <div v-show="currentTab1 == '1'" style="margin-top: 10px">
+    <div v-if="currentTab1 == '1'" style="margin-top: 10px">
         <PythonEdit  v-model="equation" language="python" />
     </div>