CodeMirror 在線代碼編輯器

像百度編輯器插件部分、菜鳥教程示例等高德地圖都在使用,這裏也記錄一下:javascript

CodeMirror是一個用於編輯器文本框textarea代碼高亮javascript插件......

vue 中使用 參見:
https://www.npmjs.com/package/vue-codemirror
https://blog.csdn.net/oumaharuki/article/details/79268498

普通使用例如:
<!doctype html>
<title>CodeMirror</title>
<meta charset="utf-8" />
<link rel="stylesheet" href="codemirror.css">
<script src="codemirror.js"></script>
<script src="xml.js"></script>
<article>
  <form style="border:1px solid red;">
    <textarea id="code" name="code"> This is an example of EJS (embedded javascript) <p>The program says <%= hello("world") %>.</p>
    <script> alert("And here is some normal JS code"); // also colored
    </script>
    <div>addd</div>
    </textarea>
  </form>
  <script>
    var editor = CodeMirror.fromTextArea(document.getElementById("code"), { lineNumbers: true, mode: "text/html", indentUnit: 4, indentWithTabs: true }); editor.on("change", function (Editor, changes) { console.log('test') console.log(Editor) console.log(changes) console.log(editor.getValue()) }); </script>
</article>

 

 

地址:http://codemirror.net/css

使用手冊:http://codemirror.net/doc/manual.htmlhtml

github地址:https://github.com/marijnh/codemirrorvue

 

使用方法等,可見前輩整理:html5

CodeMirror 使用大全 https://www.cnblogs.com/onlyonely/p/4450029.htmljava

 編輯器大全  http://www.html580.com/6399

相關文章
相關標籤/搜索