gpt4 book ai didi

textarea - 王牌编辑 : How to dynamically change the theme

转载 作者:行者123 更新时间:2023-12-04 22:22:42 24 4
gpt4 key购买 nike

如何在 Ace 编辑器中通过选择更改更改事件的主题?我能够以编程方式设置 dom ready 事件的主题。我正在调用的代码(对于两个事件)如下所示,我正在传递类似(“ace/theme/clouds”/“ace/theme/clouds_midnight”)的值。

setThemeValue = function(themeVal){
var editor = ace.edit("editor");
editor.setTheme(themeVal);
editor.getSession().setMode("ace/mode/javascript");
};

最佳答案

setTheme ” 即时更改您使用的主题,您无需重做 ace.edit("editor")。

所以我建议改为这样的代码:

// Initialize your Ace Editor
var editor = (function() {
var aceEditor = ace.edit("editor");
// default theme
aceEditor.setTheme("ace/theme/clouds");
aceEditor.getSession().setMode("ace/mode/javascript");
return aceEditor;
})();

// Change theme on the fly
editor.setTheme("ace/theme/clouds_midnight");

关于textarea - 王牌编辑 : How to dynamically change the theme,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12358856/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com