首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >摩纳哥编辑器主题不能动态更改

摩纳哥编辑器主题不能动态更改
EN

Stack Overflow用户
提问于 2021-09-14 15:59:16
回答 1查看 290关注 0票数 1

我想即时更新摩纳哥编辑的主题,但我发现它不起作用:

代码语言:javascript
运行
复制
this.editorOptions = {
                ...this.editorOptions,
                readOnly: true, // this.readOnly,
                value: this.code,
                language: 'java',
                theme: 'vs'
            };
            this.currentEditor.updateOptions(this.editorOptions);

如果我更改了readOnly,它可以正常工作,但是主题根本没有更新。

创建逻辑如下所示:

代码语言:javascript
运行
复制
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);

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

EN

回答 1

Stack Overflow用户

发布于 2022-10-08 17:30:45

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

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69181035

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档