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()
  • 相关阅读:
    「2019冬令营提高组」原样输出
    FJWC2019
    P2763 试题库问题
    P3979 遥远的国度
    P2754 [CTSC1999]家园
    P1251 餐巾计划问题
    P1382 楼房
    P1384 幸运数与排列
    P4294 [WC2008]游览计划
    P3345 [ZJOI2015]幻想乡战略游戏
  • 原文地址:https://www.cnblogs.com/wuting/p/10192515.html
Copyright © 2011-2022 走看看