當前位置:首頁 » 編程語言 » 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 10:34:15 瀏覽:540
vpn免流伺服器搭建 發布:2024-11-29 10:26:12 瀏覽:244
c源文件編譯後的擴展名為 發布:2024-11-29 10:08:40 瀏覽:924
腳本自動登錄 發布:2024-11-29 09:55:27 瀏覽:62
安卓的無線網路在哪裡 發布:2024-11-29 09:54:13 瀏覽:652
谷歌瀏覽器打開ftp 發布:2024-11-29 09:46:30 瀏覽:668
熱線女孩ftp 發布:2024-11-29 09:46:29 瀏覽:71
安卓作曲哪個軟體好用 發布:2024-11-29 09:29:30 瀏覽:903
怎麼看撥號伺服器ip 發布:2024-11-29 09:28:17 瀏覽:931
王者配置怎麼樣 發布:2024-11-29 09:22:58 瀏覽:858