1这里是利用vue来开发项目: 21、利用textare生成编辑器 3 <textarea ref="textarea"></textarea> 4 52、创建编辑器对象 6 let editJson = CodeMirror.fromTextArea(this.$refs.textarea, { 7 mode: 'application/json', // json数据高亮 8 lineNumbers: true, // 显示行号 9 theme: 'eclipse', //设置主题 10 lineWrapping: 'wrap', // 文字过长时,是换行(wrap)还是滚动(scroll),默认是滚动 11 showCursorWhenSelecting: true, // 文本选中时显示光标 12 cursorHeight: 0.85, //光标高度,默认是1 13 // 代码折叠 14 lineWrapping: true, 15 foldGutter: true, 16 gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], 17 matchBrackets: true, // 括号匹配 18 smartIndent: true, // 智能缩进 19 // 智能提示 20 extraKeys:{ 21 "Alt-/": "autocomplete", "F11": function (cm) { 22 cm.setOption("fullScreen", !cm.getOption("fullScreen")); 23 } 24 } 25 }); 26 // 设置初始值 27 editJson.setValue("输入代码\n") 28 // 获取编辑器的值 29 editJson.getValue()
CodeMirror的使用方法
Stella981
2021-10-11
1209 0 0
点赞
收藏
评论区
加载中...