2011-05-25 129 views

回答

10

像這樣的東西會幫助你。

首先設置代碼鏡

this.editor = CodeMirror.fromTextArea(document.getElementById("testAreaCodeMirror"), { 
    lineNumbers: true, 
    matchBrackets: true, 
    styleActiveLine: true, 
    theme:"eclipse", 
    mode:language 
}); 

再到模式

this.editor.setOption("mode", language); 
13

如果這是CodeMirror 2或3,請使用setOption("mode", <new mode>)(文檔號爲setOption,"mode")。

對於CodeMirror 1,請使用setParser method

+0

改變什麼CodeMirror 3? – zakdances 2013-09-06 13:19:14

+0

與版本2相同 – Marijn 2013-09-10 09:29:49