像百度编辑器插件部分、菜鸟教程示例等高德地图都在使用,这里也记录一下:
1CodeMirror是一个用于编辑器文本框textarea代码高亮javascript插件......vue 中使用 参见:https://www.npmjs.com/package/vue-codemirrorhttps://blog.csdn.net/oumaharuki/article/details/79268498普通使用例如: 2 3<!doctype html> 4<title>CodeMirror</title> 5<meta charset="utf-8" /> 6<link rel="stylesheet" href="codemirror.css"> 7<script src="codemirror.js"></script> 8<script src="xml.js"></script> 9<article> 10 <form style="border:1px solid red;"> 11 <textarea id="code" name="code"> 12 This is an example of EJS (embedded javascript) 13 <p>The program says <%= hello("world") %>.</p> 14 <script> 15 alert("And here is some normal JS code"); // also colored 16 </script> 17 <div>addd</div> 18 </textarea> 19 </form> 20 <script> 21 var editor = CodeMirror.fromTextArea(document.getElementById("code"), { 22 lineNumbers: true, 23 mode: "text/html", 24 indentUnit: 4, 25 indentWithTabs: true 26 }); 27 editor.on("change", function (Editor, changes) { 28 console.log('test') 29 console.log(Editor) 30 console.log(changes) 31 console.log(editor.getValue()) 32 }); 33 </script> 34</article>
使用手册:http://codemirror.net/doc/manual.html
github地址:https://github.com/marijnh/codemirror
使用方法等,可见前辈整理:
CodeMirror 使用大全 https://www.cnblogs.com/onlyonely/p/4450029.html