Monaco编辑器主题不能动态更改



我想在飞行中更新摩纳哥编辑器主题,但我发现它不起作用:

this.editorOptions = {
...this.editorOptions,
readOnly: true, // this.readOnly,
value: this.code,
language: 'java',
theme: 'vs'
};
this.currentEditor.updateOptions(this.editorOptions);

如果我改变readOnly,它工作得很好,但主题根本没有更新。

创建逻辑如下:

this.editorOptions = {
...this.editorOptions,
readOnly: this.readOnly,
value: this.code,
language: this.updatedType.toLowerCase(),
//theme: 'vs-dark'
theme: t === 'light' ? 'dv-light-theme' : 'dv-dark-theme'
};
this.currentEditor = monaco.editor.create(this._editorContainer.nativeElement, this.editorOptions);

请帮助并展示如何动态地更新主题。

我刚刚从https://blog.expo.dev/building-a-code-editor-with-monaco-f84b3a06deaf了解到要设置您称为monaco.editor.setTheme('<theme-name>')的主题。在我的编辑器实例上,我错误地调用了setTheme

相关内容

最新更新