[英]monaco editor theme can not be changed dynamically
我想即時更新摩納哥編輯器主題,但我發現它不起作用:
this.editorOptions = {
...this.editorOptions,
readOnly: true, // this.readOnly,
value: this.code,
language: 'java',
theme: 'vs'
};
this.currentEditor.updateOptions(this.editorOptions);
如果我更改只讀,它工作正常,但主題根本沒有更新。
創建邏輯是這樣的:
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
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.