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();
});
});

浙公网安备 33010602011771号