免费字体大全

当前位置:首页>软件下载

时间:2017-08-17   访问量:4


codemirror中文api 属性

软件大小:339KB 软件语言:中文 软件类型:国产软件 软件类别:免费软件 / 编程工具 更新时间:2017-08-17 16:12 运行环境:WinAll, WinXP, Win7, Win8, Win10 软件等级: 软件厂商: 官方网站:暂无

codemirror中文api 软件介绍

软件标签: codemirror 编程插件

codemirror是一款非常好用的代码编程插件,可以在线进行代码的编辑,支持语言广泛,可以很方便的在页面中嵌入所需要的代码编辑区,非常的好用,欢迎有需要的碰哟到绿色资源网下载使用!

官方介绍

codeMirror是一款十分强大的代码编辑插件,提供了十分丰富的API。CodeMirror是一个运行在浏览器中的代码编辑器,支持100多种语言,高度可定制。

codemirror插件特色

1.CodeMirror为各种编程语言实现关键字、函数、变量等代码高亮显示,丰富的API和可扩展功能以及多个主题样式。

2.支持语言有C、C++、C#、Java、Perl、HTML、CSS、php、javascript、Python、Lua、Go、Groovy、Ruby等。

3.以及diff、LaTeX、SQL、wiki、Markdown等文件格式。

odeMirror调用方法

href="/static/codemirror/lib/codemirror.css" rel="stylesheet" >

<script src="/static/codemirror/lib/codemirror.js"></script>

同时加载你所需要使用的脚本JS及风格样式CSS文件,如下举例:

<link href="/static/codemirror/theme/3024-night.css" rel="stylesheet"> <link href="/static/codemirror/theme/erlang-dark.css" rel="stylesheet">

<script src="/static/codemirror/mode/shell/shell.js"></script> <script src="/static/codemirror/mode/perl/perl.js"></script> <script src="/static/codemirror/mode/python/python.js"></script>

注意文件的放置位置

下一步在html页面中编写好代码:

1 <!--选择脚本编码代码--> 2 <div> 3 <input type="radio" name="script_once_type" id="script_once_type1" checked> shell 4 <input type="radio" name="script_once_type" id="script_once_type2"> bat 5 <input type="radio" name="script_once_type" id="script_once_type3"> python 6 </div> 7 8 <!--选择脚本风格代码--> 9 <div>10 <select id='select'>11 <option>default</option>12 <option>3024-night</option>13 <option selected>erlang-dark</option>14 </select>15 </div>16 17 <!--textarea-->18 <textarea id="script_once_code">19 #!/bin/sh20 </textarea>21 <textarea id="code2">22 #!/usr/bin/env python23 # -*- coding: utf8 -*-24 </textarea>

调用关键代码如下:

1 var editor = CodeMirror.fromTextArea($("#script_once_code")[0], { //script_once_code为你的textarea的ID号2 lineNumbers: true,//是否显示行号3 mode:"shell", //默认脚本编码4 lineWrapping:true, //是否强制换行5 });

JS配置代码如下:

1 //选择界面风格JS 2 $('#select').change(function(){ 3 var theme = $('#select').val(); 4 editor.setOption("theme", theme); //editor.setOption()为codeMirror提供的设置风格的方法 5 }); 6 7 //选择脚本类型JS 8 var txt1=$("#script_once_code").val(); 9 var txt2='';10 var txt3=$("#code2").val();11 $(".ck-code").click(function(){12 var txt=editor.getValue(); //editor.getValue()获取textarea中的值13 var lang=$(this).PRop("id");14 if(lang=="script_once_type1") {15 editor.setOption("mode","shell");//editor.setOption()设置脚本类型16 editor.setValue(txt1);// editor.setValue()设置textarea中的值17 }18 else if(lang=="script_once_type2") {19 editor.setOption("mode","perl");20 editor.setValue(txt2);21 }22 else {23 editor.setOption("mode","python");24 editor.setValue(txt3);25 26 }27 });

下载地址

⚠温馨提示⚠:资源来自于网络,仅供交流学习及信息展示之用,下载后请在24小时之内删除!如有侵犯您的权益,请联系我们删除。