monaco在使用中直接调用codeEditor.value会卡死

今天在整合monaco编辑器中通过codeEditoer.value标签属性值的时候页面卡死,经检测需要toRaw()获取原生属性值可以修复
 
<div id="code-editor" ref="codeEditorRef" style="min-height: 400px" />
 
onMounted(() => {
  if (!codeEditorRef.value) {
    return;
  }

  // Hover on each property to see its docs!
  codeEditor.value = monaco.editor.create(codeEditorRef.value, {
    value: value.value,
    language: "java",
    automaticLayout: true,
    colorDecorators: true,
    minimap: {
      enabled: true,
    },
    readOnly: false,
    theme: "vs-dark",
  });

  // 编辑 监听内容变化
  codeEditor.value.onDidChangeModelContent(() => {
    value.value = toRaw(codeEditor.value).getValue();
  });
});
posted @ 2024-07-24 11:35  justlearn  阅读(275)  评论(0)    收藏  举报