npm install sql-formatter Also available with yarn: yarn add sql-formatter Usage Usage as library import{format}from'sql-formatter';console.log(format('SELECT * FROM tbl',{language:'mysql'})); This will output: SELECT*FROMtbl You can also pass in configuration options: format('SELECT * FRO...
npm i -g sql-formatter-cli" (interactive "r") (save-excursion (shell-command-on-region beg end "sql-formatter-cli" nil t))) (defun sql-beautify-buffer () "Beautify SQL in buffer." (interactive) (sql-beautify-region (point-min) (point-max))) ...
一、下载两个插件 1. npm install sql-formatter --save 2.npm install codemirror --save 二、在components中创建文件来存放sql这个功能,哪里需要哪里搬 复制以下代码到文件里 <template> <textarea ref="sqlEditor" v-model="value" class="codesql"></textarea> </template> // 引入核心样式 import ...
首先,我们需要确保在Vue项目中安装了SQLFormatter。可以通过使用npm包管理器来安装SQLFormatter: shell npm installsql-formatter 安装完成后,我们可以在项目的JavaScript文件中引入SQLFormatter: javascript import SQLFormatter from 'sql-formatter'; 接下来,我们可以在Vue组件的方法中使用SQLFormatter来格式化SQL代码。例如...
1、首先使用npm安装sql-formatter插件 npm install --save sql-formatter 2、然后引入该sql-formatter.js文件 import sqlFormatter from "sql-formatter"; 3、接下来就是针对需要格式化的代码调用该方法就OK啦 /*代码格式化*/format(){/*获取文本编辑器内容*/letsqlContent=""; ...
sql-formatter - npm (npmjs.com) const sqlFormatter = require('@/utils/sqlFormatter') let sql = `select count(1) as cnt from t_user where id < 7`; // 格式化 // let sqlF = sqlFormatter.format(sql); let sqlF = sqlFormatter.format(sql, { ...
npm install sql-formatter Usage importsqlFormatterfrom"sql-formatter";console.log(sqlFormatter.format("SELECT * FROM table1")); This will output: SELECT * FROM table1 You can also pass in configuration options: sqlFormatter.format("SELECT *", {language:"n1ql",// Defaults to "sql"indent:"...
npm install sql-formatter 或者 shell yarn add sql-formatter 这将会下载并安装SQLFormatter的最新版本。 第二步:引入SQLFormatter 在Vue项目的代码中,我们需要引入SQLFormatter,以便在需要的时候使用它。可以在需要使用SQLFormatter的组件中引入它。打开需要引入SQLFormatter的组件文件,并在文件头部添加以下代码: javascrip...
npm install sql-formatter import sqlFormatter from 'sql-formatter'; function formatDataToSQL(data) { const sql = `SELECT * FROM table WHERE id = ${data.id};`; return sqlFormatter.format(sql); } 三、在Vue组件中显示格式化后的SQL数据 ...
npm install sql-formatter --save //sql语句格式化 版本2.3.3(不然报错) npm install vue-codemirror --save //用于sql语句关键词高亮 1. 2. 2.引入 import sqlFormatter from 'sql-formatter'; import CodeMirror from 'codemirror/lib/codemirror'; ...