CodeMirror的使用方法
生活随笔
收集整理的這篇文章主要介紹了
CodeMirror的使用方法
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
這里是利用vue來開發項目:
1、利用textare生成編輯器<textarea ref="textarea"></textarea>2、創建編輯器對象let editJson = CodeMirror.fromTextArea(this.$refs.textarea, {mode: 'application/json', // json數據高亮lineNumbers: true, // 顯示行號theme: 'eclipse', //設置主題lineWrapping: 'wrap', // 文字過長時,是換行(wrap)還是滾動(scroll),默認是滾動showCursorWhenSelecting: true, // 文本選中時顯示光標cursorHeight: 0.85, //光標高度,默認是1// 代碼折疊lineWrapping: true,foldGutter: true,gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],matchBrackets: true, // 括號匹配smartIndent: true, // 智能縮進// 智能提示
extraKeys:{"Alt-/": "autocomplete", "F11": function (cm) {cm.setOption("fullScreen", !cm.getOption("fullScreen"));}}});// 設置初始值editJson.setValue("輸入代碼\n")// 獲取編輯器的值editJson.getValue()
?
轉載于:https://www.cnblogs.com/wuting/p/10192515.html
總結
以上是生活随笔為你收集整理的CodeMirror的使用方法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C#获取文件夹下的所有文件的方法
- 下一篇: Dynamic Rankings——带修