如何使用CodeMirror动态切换模式?
我有默认设置,但需要切换它。
发布于 2014-06-26 15:45:41
像这样的东西会对你有帮助。
首先,设置CodeMirror:
this.editor = CodeMirror.fromTextArea(document.getElementById("textAreaCodeMirror"), {
lineNumbers: true,
matchBrackets: true,
styleActiveLine: true,
theme:"eclipse",
mode:language
});然后,更改模式
this.editor.setOption("mode", language);发布于 2011-05-27 04:45:37
如果是CodeMirror 2或3,则使用setOption("mode", <new mode>) (用于setOption、"mode"的文档)。
对于CodeMirror 1,请使用setParser method。
https://stackoverflow.com/questions/6130563
复制相似问题