zoukankan      html  css  js  c++  java
  • 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("输入代码
    ")
     // 获取编辑器的值
     editJson.getValue()
  • 相关阅读:
    哈希及哈希算法
    十四章课后练习题
    第十章课后题----3
    20151015----知识整理
    第十章练习题----2
    加热水杯
    函数
    异常反馈
    20151013知识体系整理,需与20151011相整合
    Java随机输出验证码包含数字、字母、汉字
  • 原文地址:https://www.cnblogs.com/wuting/p/10192515.html
Copyright © 2011-2022 走看看