Эх сурвалжийг харах

fix: 修复 editor 使用ref 赋值导致的 卡死

lanceJiang 8 сар өмнө
parent
commit
df5287b947

+ 3 - 4
src/components/MonacoEditor/index.vue

@@ -27,7 +27,7 @@ const props = defineProps({
 })
 const emits = defineEmits(['update:modelValue', 'change', 'editorDidMount'])
 const monacoRef = ref<HTMLElement>()
-const editor = ref()
+const editor = shallowRef()
 const _getValue = () => {
 	return editor.value?.getValue()
 }
@@ -77,9 +77,8 @@ watch(
 	}
 )
 onBeforeUnmount(() => {
-	if (editor.value) {
-		editor.value.dispose()
-	}
+	editor.value?.dispose()
+	editor.value = null
 })
 defineExpose({
 	getValue: _getValue