Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/85.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用js在ace编辑器中动态更改editor.setoptions_Javascript_Html_Ace Editor - Fatal编程技术网

Javascript 使用js在ace编辑器中动态更改editor.setoptions

Javascript 使用js在ace编辑器中动态更改editor.setoptions,javascript,html,ace-editor,Javascript,Html,Ace Editor,我正在制作一个小的HTML/CSS/js live编辑器,其中遇到了一些问题。设置编辑器后,如何动态更改编辑器的选项?这是代码 <input class="form-check-input" type="checkbox" id="gridCheck1" checked> ... <div id="editor"></div> <iframe id="

我正在制作一个小的HTML/CSS/js live编辑器,其中遇到了一些问题。设置编辑器后,如何动态更改编辑器的选项?这是代码

<input class="form-check-input" type="checkbox" id="gridCheck1" checked>
...
<div id="editor"></div>

      <iframe id="iframe" frameborder="0"> </iframe>
      <script>
        function update() {
          var idoc = document.getElementById("iframe").contentWindow.document;

          idoc.open();
          idoc.write(editor.getValue());
          idoc.close();
        }

        function setupEditor() {
         ....
         editor.setOptions({
            fontSize: "16pt",
            showLineNumbers: true,
            showGutter: true,
            vScrollBarAlwaysVisible: false,
            enableBasicAutocompletion: true,
            enableLiveAutocompletion: true,
            enableSnippets: true,
            showLineNumbers: true,
            wrap: true,
          });
        ....
         }
      setupEditor();
      update();
    </script>

...
函数更新(){
var idoc=document.getElementById(“iframe”).contentWindow.document;
idoc.open();
write(editor.getValue());
idoc.close();
}
函数setupEditor(){
....
editor.setOptions({
字体大小:“16磅”,
showlinenumber:正确,
是的,
vScrollBarAlwaysVisible:错误,
enableBasicAutocompletion:正确,
enableLiveAutocompletion:true,
enableSnippets:true,
showlinenumber:正确,
是的,
});
....
}
setupEditor();
更新();
但问题是,即使我接受一个变量并根据复选框的checked属性更改其值,我也不能多次更改这些值,因为setup editor函数只运行一次,editor.setOptions在update函数中不起作用


主题也是如此。请任何人帮忙

使用要应用于编辑器的新选项再次调用editor.setOptions