我想即时更新摩纳哥编辑的主题,但我发现它不起作用:
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);
请帮助并演示如何动态更新主题。
发布于 2022-10-08 17:30:45
我刚刚从https://blog.expo.dev/building-a-code-editor-with-monaco-f84b3a06deaf中了解到,设置您称之为monaco.editor.setTheme('<theme-name>')
的主题。我在编辑器实例上错误地调用了setTheme
。
https://stackoverflow.com/questions/69181035
复制相似问题