当前位置:首页 » 编程语言 » sqlhint

sqlhint

发布时间: 2024-02-06 01:54:48

1. 如何采用element-plus,基于codemirror6实现sql在线编辑器

js在线sql编辑器,下载后导入IDE工具中,在浏览器访问sql-editor-master/index.html ,效果如下(含括号高亮显示、显示折叠栏):
codeMirror官网https://codemirror.net/, 官网js/css资源文件,也可自行去官网下载,但是官网比较慢,需引入的核心页面代码:
<link rel="stylesheet" href="css/codemirror.css" />
<link rel="stylesheet" href="test/addon/fold/foldgutter.css">
<link rel="stylesheet" href="css/theme/dracula.css" />
<link rel="stylesheet" href="css/show-hint.css" />
<link rel="stylesheet" href="js/jquery-easyui/themes/default/easyui.css">
<link rel="stylesheet" href="js/layui/css/layui.css">

<link rel="stylesheet" href="css/index.css" />
<script type="text/javascript">var baseUrl ="";</script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery-easyui/jquery.easyui.min.js"></script>
<script type="text/javascript" src="js/jquery-easyui/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="js/editor/codemirror.js"></script>
<!-- 折叠栏显示 -->
<script type="text/javascript" src="test/addon/fold/foldcode.js"></script>
<script type="text/javascript" src="test/addon/fold/foldgutter.js"></script>
<script type="text/javascript" src="test/addon/fold/comment-fold.js"></script>
<!-- 括号高亮匹配 -->
<script type="text/javascript" src="test/addon/fold/matchbrackets.js"></script>

<script type="text/javascript" src="js/editor/sublime.js"></script>
<script type="text/javascript" src="js/editor/sql.js"></script>
<script type="text/javascript" src="js/editor/sql-hint.js"></script>
<script type="text/javascript" src="js/editor/show-hint.js"></script>
<!-- sql格式 -->
<script type="text/javascript" src="js/editor/formatting.js"></script>
<script type="text/javascript" src="js/editor/sql-formatter.min.js"></script>

<script type="text/javascript" src="js/layui/layui.js"></script>
<script type="text/javascript" src="js/index.js"></script>

<textarea id="code"></textarea>

核心js代码:

//根据DOM元素的id构造出一个编辑器
var editor=CodeMirror.fromTextArea(document.getElementById("code"),{
mode:"text/c-mysql", //实现Java代码高亮
lineNumbers:true,
matchBrackets: true, //括号高亮匹配
theme:"default",
keyMap: "default",
extraKeys:{"Tab":"autocomplete"},
hint: CodeMirror.hint.sql,
lineWrapping: true, //是否换行
foldGutter: true, //是否折叠
gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"], //添加行号栏,折叠栏
hintOptions: {
tables: tablewords

}

});

输入关键词提示等信息的配置:allWords.json

动态设置表字段等信息:

let tableWords = {"al": []};
let tableName = "tn_user";
tableWords[tableName].push("userId");
editor.setOption("hintOptions", {"tables": tableWords});
tableWords json格式如下:

"tableWords": {
"cp_sku": [
"skuid",
"cpbh",
"tcbh"
],
"user_info": [
"user_id",
"user_token",
"user_name",
"user_type",
"password"
]
}

热点内容
电脑怎么登远程服务器 发布:2024-11-29 12:32:20 浏览:124
先来先服务进程调度算法 发布:2024-11-29 12:30:12 浏览:628
mysql存储过程循环表中的数据 发布:2024-11-29 12:04:02 浏览:600
相机存储器一般是什么 发布:2024-11-29 11:59:51 浏览:295
传奇服务器源码 发布:2024-11-29 11:43:15 浏览:820
新手机如何登录微信密码忘记了 发布:2024-11-29 11:34:34 浏览:544
笔记本配置低怎么玩lol 发布:2024-11-29 11:34:32 浏览:461
如何在iphone上玩安卓号 发布:2024-11-29 11:24:21 浏览:754
服务器店铺怎么取名 发布:2024-11-29 11:19:26 浏览:4
phpapache日志 发布:2024-11-29 11:07:26 浏览:310