1 var myTextarea = document.getElementById('editor'); 2 var CodeMirrorEditor = CodeMirror.fromTextArea(myTextarea, { 3 mode: "text/javascript", //高亮语言 4 lineNumbers: true,//显示行数 5 theme: "seti",//主题 6 // fullScreen:true,//全屏模式 7 // 500, 8 height: 800, 9 //readOnly:true, 10 matchBrackets: true,//括号匹配 11 extraKeys: {"Ctrl-Space": "autocomplete"}//ctrl-space唤起智能提示 12 });
1 //html代码 2 <div class="layui-form-item layui-form-text"> 3 <label class="layui-form-label">脚本代码</label> 4 <div class="editor" style=" 96%;margin-left:38px;margin-right:30px;margin-top:10px;border-radius:2px;"> 5 <textarea id="editor" name="editor"></textarea> 6 </div> 7 </div>