主頁 > 企業開發 > Vue 基于vue-codemirror實作的代碼編輯器

Vue 基于vue-codemirror實作的代碼編輯器

2020-09-15 03:19:41 企業開發

基于vue-codemirror實作的代碼編輯器

開發環境

jshint 2.11.1

jsonlint 1.6.3

script-loader 0.7.2

vue 2.6.11

vue-codemirror 4.0.6

element-ui 2.13.1 (使用到element-ui message組件,提示錯誤訊息,如果不想安裝該組件,替換編輯器中的this.$message所在行函式代碼即可)

 

功能介紹

1、  支持不同的代碼編輯模式

目前僅支持支持json, sql, javascript,css,xml, html,yaml, markdown, python編輯模式,默認為 json

 

2、  支持使用不同主題

支持62種主題,默認為 blackboard

 

3、  支持API編程

目前支持修改樣式,獲取內容,修改編輯框內容值

 

4、  支持復制,黏貼,剪切,撤銷等常見操作

 

5、  支持檔案拖拽匯入

支持滑鼠拖拽檔案到編輯框,編輯框自動展示被拖拽檔案的內容(當然,不是所有檔案都可以,比如word檔案,.exe檔案就不行)

 

6、  支持json格式化

1)json編輯模式下,滑鼠失去焦點時自動格式化json字串,支持定義開關該特性

2)支持自定義格式化化縮進,支持字符或數字,最大不超過10,默認縮進2個空格

3)json編輯模式下,黏貼json字串到編輯框時,支持自動格式化編輯框內容

4)json編輯模式下,支持按Ctrl+Alt+L快捷鍵主動格式化當前json格式字符內容

           

7、  支持顯示代碼行號

 

8、  支持編輯時“智能”縮進

 

9、  支持代碼折疊/展開

支持json, sql, javascript,css,xml, html,yaml, markdown, python等

 

10、 支持靜態代碼語法檢查

目前僅支持支持 json,javascript

 

11、 支持批量替換

操作方法:

按Ctrl + Shift + r鍵,彈出框中輸入要被替換的內容,回車,然后再次輸入用于替換的內容,回車即可,

 

12、 支持快速搜索

操作方法:

按Ctrl + F,彈出框中輸入要查找內容,回車

 

13、 支持跳轉到指定行

操作方法:

按Alt + G 快捷鍵, 彈出快對話框中輸入行號,回車即可

 

14、 支持滑鼠點擊高亮匹配單詞

使用場景舉例:滑鼠點擊某個單詞,高亮其它區域和被點擊單詞相同的單詞

 

15、 支持自動補全提示

目前僅支持 sql,javascript,html,python

 

備注:出現自動補全提示時,按tab鍵可自動補全

 

16、 支持自動補全括號,單、雙引號

支持自動補全括號:(),[],{},單引號,雙引號:'' ""

 

使用場景舉例:輸入 [ 時,自動顯示為[],并且把游標定位在括號中間

 

17、 支持自動補全xml標簽

支持輸入完開放xml、html元素標簽時,自動補齊右側閉合標簽、或者輸入完 </ 時,自動補齊閉合標簽

 

使用場景舉例:輸入完<book>時自動補齊右側</book>

 

18、 支持自動匹配xml標簽

xml、html編輯模式下,支持自動匹配標簽

 

使用場景舉例:滑鼠點擊時xml標簽時(開放標簽或閉合標簽),自動高亮另一半標簽

 

19、 支持自動匹配括號

使用場景舉例:游標點擊緊挨{、]括號左、右側時,自動突出顯示匹配的括號 }、]

 

20、 支持游標所在當前行背景高亮

 

21、 支持高亮選中內容

使用場景舉例:按下滑鼠左鍵,拖拽選擇內容時,高亮被選中內容,文字反白

主要依賴安裝

npm install jsonlint

npm install jshint

npm install script-loader

npm install vue-codemirror

npm install element-ui

src/main.js配置

添加以下帶背景色的部分的配置

import Vue from "vue"

import ElementUI from "element-ui"

import "element-ui/lib/theme-chalk/index.css"

 

...略

// 引入jshint用于實作js自動補全提示 

import jshint from "jshint";

window.JSHINT = jshint.JSHINT;

 

// 引入代碼編輯器 

import { codemirror } from "vue-codemirror";

import "codemirror/lib/codemirror.css";

 

import App from "./app/App"

 

...略

 

Vue.use(ElementUI);

Vue.use(codemirror);

 

...略

 

編輯器組件實作

<template>

    <codemirror

        ref="myCm"

        :value="https://www.cnblogs.com/shouke/p/editorValue"

        :options="cmOptions"

        @changes="onCmCodeChanges"

        @blur="onCmBlur"

        @keydown.native="onKeyDown"

        @mousedown.native="onMouseDown"

        @paste.native="OnPaste"

    ></codemirror>

</template>

 

<script>

import { codemirror } from "vue-codemirror";

 

import "codemirror/theme/blackboard.css";

import "codemirror/mode/javascript/javascript.js"; 

import "codemirror/mode/xml/xml.js";

import "codemirror/mode/htmlmixed/htmlmixed.js"; 

import "codemirror/mode/css/css.js";

import "codemirror/mode/yaml/yaml.js";

import "codemirror/mode/sql/sql.js";

import "codemirror/mode/python/python.js";

import "codemirror/mode/markdown/markdown.js";

import "codemirror/addon/hint/show-hint.css";

import "codemirror/addon/hint/show-hint.js"; 

import "codemirror/addon/hint/javascript-hint.js";

import "codemirror/addon/hint/xml-hint.js";

import "codemirror/addon/hint/css-hint.js"; 

import "codemirror/addon/hint/html-hint.js";

import "codemirror/addon/hint/sql-hint.js";

import "codemirror/addon/hint/anyword-hint.js"; 

import "codemirror/addon/lint/lint.css";

import "codemirror/addon/lint/lint.js"; 

import "codemirror/addon/lint/json-lint"; 

require("script-loader!jsonlint");

// import "codemirror/addon/lint/html-lint.js";

// import "codemirror/addon/lint/css-lint.js";  

import "codemirror/addon/lint/javascript-lint.js"; 

import "codemirror/addon/fold/foldcode.js"; 

import "codemirror/addon/fold/foldgutter.js"; 

import "codemirror/addon/fold/foldgutter.css";

import "codemirror/addon/fold/brace-fold.js"; 

import "codemirror/addon/fold/xml-fold.js";

import "codemirror/addon/fold/comment-fold.js"; 

import "codemirror/addon/fold/markdown-fold.js"; 

import "codemirror/addon/fold/indent-fold.js"; 

import "codemirror/addon/edit/closebrackets.js"; 

import "codemirror/addon/edit/closetag.js";

import "codemirror/addon/edit/matchtags.js"; 

import "codemirror/addon/edit/matchbrackets.js";

import "codemirror/addon/selection/active-line.js"; 

import "codemirror/addon/search/jump-to-line.js"; 

import "codemirror/addon/dialog/dialog.js";

import "codemirror/addon/dialog/dialog.css";

import "codemirror/addon/search/searchcursor.js"; 

import "codemirror/addon/search/search.js"; 

import "codemirror/addon/display/autorefresh.js"; 

import "codemirror/addon/selection/mark-selection.js"; 

import "codemirror/addon/search/match-highlighter.js"; 

 

export default {

    components: {

        codemirror

    },

    props: ["cmTheme", "cmMode", "autoFormatJson", "jsonIndentation"],

    data() {

        return {

            editorValue: "",

            cmOptions: {

                theme:

                    !this.cmTheme || this.cmTheme == "default"

                        ? "blackboard"

                        : this.cmTheme, 

                mode:

                    !this.cmMode || this.cmMode == "default"

                        ? "application/json"

                        : this.cmMode, 

                lineWrapping: true, 

                lineNumbers: true, 

                autofocus: true, 

                smartIndent: false, 

                autocorrect: true, 

                spellcheck: true, 

                extraKeys: {

                    Tab: "autocomplete", 

                    "Ctrl-Alt-L": () => {

                        try {

                            if (

                                this.cmOptions.mode == "application/json" &&

                                this.editorValue

                            ) {

                                this.editorValue = this.formatStrInJson(

                                    this.editorValue

                                );

                            }

                        } catch (e) {

                            this.$message.error(

                                "格式化代碼出錯:" + e.toString()

                            );

                        }

                    }                    

                },

                lint: true,

                gutters: [

                    "CodeMirror-lint-markers", 

                    "CodeMirror-linenumbers", 

                    "CodeMirror-foldgutter" 

                ],

                foldGutter: true,

                autoCloseBrackets: true, 

                autoCloseTags: true,

                matchTags: { bothTags: true },

                matchBrackets: true, 

                styleActiveLine: true, 

                autoRefresh: true, 

                highlightSelectionMatches: {

                    minChars: 2,

                    style: "matchhighlight", 

                    showToken: true 

                },

                styleSelectedText: true,

                enableAutoFormatJson:

                    this.autoFormatJson == null ? true : this.autoFormatJson,

 

                defaultJsonIndentation:

                    !this.jsonIndentation ||

                    typeof this.jsonIndentation != typeof 1

                        ? 2

                        : this.jsonIndentation 

            },

            enableAutoFormatJson:

                this.autoFormatJson == null ? true : this.autoFormatJson, 

            defaultJsonIndentation:

                !this.jsonIndentation || typeof this.jsonIndentation != typeof 1

                    ? 2

                    : this.jsonIndentation 

        };

    },

 

    watch: {

        cmTheme: function(newValue, oldValue) {

            try {

                let theme =

                    this.cmTheme == "default" ? "blackboard" : this.cmTheme;

                require("codemirror/theme/" + theme + ".css");

                this.cmOptions.theme = theme;

                this.resetLint();

            } catch (e) {

                this.$message.error("切換編輯器主題出錯:" + e.toString());

            }

        },

        cmMode: function(newValue, oldValue) {

            this.$set(this.cmOptions, "mode", this.cmMode);

            this.resetLint();

            this.resetFoldGutter();

        }

    },

    methods: {

        resetLint() {

            if (!this.$refs.myCm.codemirror.getValue()) {

                this.$nextTick(() => {

                    this.$refs.myCm.codemirror.setOption("lint", false);

                });

                return;

            }

            this.$refs.myCm.codemirror.setOption("lint", false);

            this.$nextTick(() => {

                this.$refs.myCm.codemirror.setOption("lint", true);

            });

        },

 

        resetFoldGutter() {

           this.$refs.myCm.codemirror.setOption("foldGutter", false);

            this.$nextTick(() => {

                this.$refs.myCm.codemirror.setOption("foldGutter", true);

            });

        },

        // 修改編輯框樣式

        setStyle(style) {

            try {

                this.$nextTick(() => {

                    let cm = this.$refs.myCm.$el.querySelector(".CodeMirror");

                    if (cm) {

                        cm.style.cssText = style;

                    } else {

                        this.$message.error(

                            "未找到編輯器元素,修改編輯器樣式失敗"

                        );

                    }

                });

            } catch (e) {

                this.$message.error("修改編輯器樣式失敗:" + e.toString());

            }

        },

        // 獲取值

        getValue() {

            try {

                return this.$refs.myCm.codemirror.getValue();

            } catch (e) {

                let errorInfo = e.toString();

                this.$message.error("獲取編輯框內容失敗:" + errorInfo);

                return errorInfo;

            }

        },

        // 修改值

        setValue(value) {

            try {

                if (typeof value != typeof "") {

                    this.$message.error(

                        "修改編輯框內容失敗:編輯寬內容只能為字串"

                    );

                    return;

                }

                if (this.cmOptions.mode == "application/json") {

                    this.editorValue = this.formatStrInJson(value);

                } else {

                    this.editorValue = value;

                }

            } catch (e) {

                this.$message.error("修改編輯框內容失敗:" + e.toString());

            }

        },

        // 黏貼事件處理函式

        OnPaste(event) {

            if (this.cmOptions.mode == "application/json") {

                try {

                    this.editorValue = this.formatStrInJson(this.editorValue);

                } catch (e) {

                    // 啥都不做

                }

            }

        },

        // 失去焦點時處理函式

        onCmBlur(cm, event) {

            try {

                let editorValue = cm.getValue();

                if (this.cmOptions.mode == "application/json" && editorValue) {

                    if (!this.enableAutoFormatJson) {

                        return;

                    }

                    this.editorValue = this.formatStrInJson(editorValue);

                }

            } catch (e) {

                // 啥也不做

            }

        },

        // 按下鍵盤事件處理函式

        onKeyDown(event) {

            const keyCode = event.keyCode || event.which || event.charCode;

 

            const keyCombination =

                event.ctrlKey || event.altKey || event.metaKey;

 

            if (!keyCombination && keyCode > 64 && keyCode < 123) {

                this.$refs.myCm.codemirror.showHint({ completeSingle: false });

            }

        },

        // 按下滑鼠時事件處理函式

        onMouseDown(event) {

            this.$refs.myCm.codemirror.closeHint();

        },

        onCmCodeChanges(cm, changes) {

            this.editorValue = cm.getValue();

            this.resetLint();

        },

        // 格式化字串為json格式字串

        formatStrInJson(strValue) {

            return JSON.stringify(

                JSON.parse(strValue),

                null,

                this.defaultJsonIndentation

            );

        }

    },

    created() {

        try {

            if (!this.editorValue) {

                this.cmOptions.lint = false;

                return;

            }

 

            if (this.cmOptions.mode == "application/json") {

                if (!this.enableAutoFormatJson) {

                    return;

                }

                this.editorValue = this.formatStrInJson(this.editorValue);

            }

        } catch (e) {

            console.log("初始化codemirror出錯:" + e);

            // this.$message.error("初始化codemirror出錯:" + e);

        }

    }

};

</script>

 

<style>

.CodeMirror-selected {

    background-color: blue !important;

}

 

.CodeMirror-selectedtext {

    color: white !important;

}

 

.cm-matchhighlight {

    background-color: #ae00ae;

}

</style>

 

參考編輯器組件

<template>

    <div >

        <div >

            <span>請選擇主題</span>

            <el-select v-model="cmTheme" placeholder="請選擇" size="small" style="width:150px">

                <el-option v-for="item in cmThemeOptions" :key="item" :label="item" :value="https://www.cnblogs.com/shouke/p/item"></el-option>

            </el-select>

            <span style="margin-left: 10px">請選擇編輯模式</span>

            <el-select

                v-model="cmEditorMode"

                placeholder="請選擇"

                size="small"

                style="width:150px"

                @change="onEditorModeChange"

            >

                <el-option

                    v-for="item in cmEditorModeOptions"

                    :key="item"

                    :label="item"

                    :value="https://www.cnblogs.com/shouke/p/item"

                ></el-option>

            </el-select>

            <el-button type="primary" size="small" style="margin-left:10x" @click="setStyle">修改樣式</el-button>

            <el-button type="primary" size="small" style="margin-left:10x" @click="getValue">獲取內容</el-button>

            <el-button type="primary" size="small" style="margin-left:10x" @click="setValue">修改內容</el-button>

        </div>

 

        <code-mirror-editor

            ref="cmEditor"

            :cmTheme="cmTheme"

            :cmMode="cmMode"

            :autoFormatJson="autoFormatJson"

            :jsonIndentation="jsonIndentation"

        ></code-mirror-editor>

    </div>

</template>

 

<script>

// 使用時需要根據CodeMirrorEditor.vue的實際存放路徑,調整from后面的組件路徑,以便正確參考

import CodeMirrorEditor from "@/common/components/public/CodeMirrorEditor";

 

export default {

    components: {

        CodeMirrorEditor

    },

    data() {

        return {

            cmTheme: "default", // codeMirror主題

            // codeMirror主題選項

            cmThemeOptions: [

                "default",

                "3024-day",

                "3024-night",

                "abcdef",

                "ambiance",

                "ayu-dark",

                "ayu-mirage",

                "base16-dark",

                "base16-light",

                "bespin",

                "blackboard",

                "cobalt",

                "colorforth",

                "darcula",

                "dracula",

                "duotone-dark",

                "duotone-light",

                "eclipse",

                "elegant",

                "erlang-dark",

                "gruvbox-dark",

                "hopscotch",

                "icecoder",

                "idea",

                "isotope",

                "lesser-dark",

                "liquibyte",

                "lucario",

                "material",

                "material-darker",

                "material-palenight",

                "material-ocean",

                "mbo",

                "mdn-like",

                "midnight",

                "monokai",

                "moxer",

                "neat",

                "neo",

                "night",

                "nord",

                "oceanic-next",

                "panda-syntax",

                "paraiso-dark",

                "paraiso-light",

                "pastel-on-dark",

                "railscasts",

                "rubyblue",

                "seti",

                "shadowfox",

                "solarized dark",

                "solarized light",

                "the-matrix",

                "tomorrow-night-bright",

                "tomorrow-night-eighties",

                "ttcn",

                "twilight",

                "vibrant-ink",

                "xq-dark",

                "xq-light",

                "yeti",

                "yonce",

                "zenburn"

            ],

            cmEditorMode: "default", // 編輯模式

            // 編輯模式選項

            cmEditorModeOptions: [

                "default",

                "json",

                "sql",

                "javascript",

                "css",

                "xml",

                "html",

                "yaml",

                "markdown",

                "python"

            ],

            cmMode: "application/json", //codeMirror模式

            jsonIndentation: 2, // json編輯模式下,json格式化縮進 支持字符或數字,最大不超過10,默認縮進2個空格

            autoFormatJson: true // json編輯模式下,輸入框失去焦點時是否自動格式化,true 開啟, false 關閉

        };

    },

    methods: {

        // 切換編輯模式事件處理函式

        onEditorModeChange(value) {

            switch (value) {

                case "json":

                    this.cmMode = "application/json";

                    break;

                case "sql":

                    this.cmMode = "sql";

                    break;

                case "javascript":

                    this.cmMode = "javascript";

                    break;

                case "xml":

                    this.cmMode = "xml";

                    break;

                case "css":

                    this.cmMode = "css";

                    break;

                case "html":

                    this.cmMode = "htmlmixed";

                    break;

                case "yaml":

                    this.cmMode = "yaml";

                    break;

                case "markdown":

                    this.cmMode = "markdown";

                    break;

                case "python":

                    this.cmMode = "python";

                    break;

                default:

                    this.cmMode = "application/json";

            }

        },

        // 修改樣式(不推薦,建議參考<style>中的樣式,提前配置好樣式)

        setStyle() {

            let styleStr =

                "position: absolute; top: 80px; left: 50px; right: 200px; bottom: 20px; padding: 2px; height: auto;";

            this.$refs.cmEditor.setStyle(styleStr);

        },

        //獲取內容

        getValue() {

            let content = this.$refs.cmEditor.getValue();

            console.log(content);

        },

        //修改內容

        setValue() {

            let jsonValue = {

                name: "laiyu",

                addr: "廣東省深圳市",

                other: "nothing",

                tel: "168888888",

                intro: [{ item1: "item1" }]

            };

 

            this.$refs.cmEditor.setValue(JSON.stringify(jsonValue));

        }

    }

};

</script>

 

<style>

.CodeMirror {

    position: absolute;

    top: 80px;

    left: 2px;

    right: 5px;

    bottom: 0px;

    padding: 2px;

    height: auto; 

    overflow-y: auto;

}

</style>

 

<style lang="scss" scoped>

.code-mirror-div {

    position: absolute;

    top: 0px;

    left: 2px;

    right: 5px;

    bottom: 0px;

    padding: 2px;

    .tool-bar {

        top: 20px;

        margin: 30px 2px 0px 20px;

    }

}

</style>

 

效果展示

 

 

 

 

 

 

  1. 1.  支持多主題

 

 

 

 

  1. 2. 代碼折疊/展開

 

 

 

 

 

 

 

 

 

 

 

 

  1. 3. 靜態代碼語法檢查

 

 

 

 

 

 

 

  1. 4.   查找內容

 

 

 

 

  1. 5.   批量替換內容

 

 

 

 

  1. 6.   跳轉到指定行

 

 

 

 

  1. 7. 自動補全提示

 

 

 

 

 

 

 

 

 

 

 

 

 

  1. 8. 自動匹配xml標簽

 

 

  

 

  1. 9.   自動匹配括號

 

 

  1. 10.  滑鼠點擊高亮匹配單詞

 

 

 

 

 

 

轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/41413.html

標籤:JavaScript

上一篇:函式防抖和節流

下一篇:JavaScript 監聽組合按鍵

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • IEEE1588PTP在數字化變電站時鐘同步方面的應用

    IEEE1588ptp在數字化變電站時鐘同步方面的應用 京準電子科技官微——ahjzsz 一、電力系統時間同步基本概況 隨著對IEC 61850標準研究的不斷深入,國內外學者提出基于IEC61850通信標準體系建設數字化變電站的發展思路。數字化變電站與常規變電站的顯著區別在于程序層傳統的電流/電壓互 ......

    uj5u.com 2020-09-10 03:51:52 more
  • HTTP request smuggling CL.TE

    CL.TE 簡介 前端通過Content-Length處理請求,通過反向代理或者負載均衡將請求轉發到后端,后端Transfer-Encoding優先級較高,以TE處理請求造成安全問題。 檢測 發送如下資料包 POST / HTTP/1.1 Host: ac391f7e1e9af821806e890 ......

    uj5u.com 2020-09-10 03:52:11 more
  • 網路滲透資料大全單——漏洞庫篇

    網路滲透資料大全單——漏洞庫篇漏洞庫 NVD ——美國國家漏洞庫 →http://nvd.nist.gov/。 CERT ——美國國家應急回應中心 →https://www.us-cert.gov/ OSVDB ——開源漏洞庫 →http://osvdb.org Bugtraq ——賽門鐵克 →ht ......

    uj5u.com 2020-09-10 03:52:15 more
  • 京準講述NTP時鐘服務器應用及原理

    京準講述NTP時鐘服務器應用及原理京準講述NTP時鐘服務器應用及原理 安徽京準電子科技官微——ahjzsz 北斗授時原理 授時是指接識訓通過某種方式獲得本地時間與北斗標準時間的鐘差,然后調整本地時鐘使時差控制在一定的精度范圍內。 衛星導航系統通常由三部分組成:導航授時衛星、地面檢測校正維護系統和用戶 ......

    uj5u.com 2020-09-10 03:52:25 more
  • 利用北斗衛星系統設計NTP網路時間服務器

    利用北斗衛星系統設計NTP網路時間服務器 利用北斗衛星系統設計NTP網路時間服務器 安徽京準電子科技官微——ahjzsz 概述 NTP網路時間服務器是一款支持NTP和SNTP網路時間同步協議,高精度、大容量、高品質的高科技時鐘產品。 NTP網路時間服務器設備采用冗余架構設計,高精度時鐘直接來源于北斗 ......

    uj5u.com 2020-09-10 03:52:35 more
  • 詳細解讀電力系統各種對時方式

    詳細解讀電力系統各種對時方式 詳細解讀電力系統各種對時方式 安徽京準電子科技官微——ahjzsz,更多資料請添加VX 衛星同步時鐘是我京準公司開發研制的應用衛星授時時技術的標準時間顯示和發送的裝置,該裝置以M國全球定位系統(GLOBAL POSITIONING SYSTEM,縮寫為GPS)或者我國北 ......

    uj5u.com 2020-09-10 03:52:45 more
  • 如何保證外包團隊接入企業內網安全

    不管企業規模的大小,只要企業想省錢,那么企業的某些服務就一定會采用外包的形式,然而看似美好又經濟的策略,其實也有不好的一面。下面我通過安全的角度來聊聊使用外包團的安全隱患問題。 先看看什么服務會使用外包的,最常見的就是話務/客服這種需要大量重復性、無技術性的服務,或者是一些銷售外包、特殊的職能外包等 ......

    uj5u.com 2020-09-10 03:52:57 more
  • PHP漏洞之【整型數字型SQL注入】

    0x01 什么是SQL注入 SQL是一種注入攻擊,通過前端帶入后端資料庫進行惡意的SQL陳述句查詢。 0x02 SQL整型注入原理 SQL注入一般發生在動態網站URL地址里,當然也會發生在其它地發,如登錄框等等也會存在注入,只要是和資料庫打交道的地方都有可能存在。 如這里http://192.168. ......

    uj5u.com 2020-09-10 03:55:40 more
  • [GXYCTF2019]禁止套娃

    git泄露獲取原始碼 使用GET傳參,引數為exp 經過三層過濾執行 第一層過濾偽協議,第二層過濾帶引數的函式,第三層過濾一些函式 preg_replace('/[a-z,_]+\((?R)?\)/', NULL, $_GET['exp'] (?R)參考當前正則運算式,相當于匹配函式里的引數 因此傳遞 ......

    uj5u.com 2020-09-10 03:56:07 more
  • 等保2.0實施流程

    流程 結論 ......

    uj5u.com 2020-09-10 03:56:16 more
最新发布
  • 使用Django Rest framework搭建Blog

    在前面的Blog例子中我們使用的是GraphQL, 雖然GraphQL的使用處于上升趨勢,但是Rest API還是使用的更廣泛一些. 所以還是決定回到傳統的rest api framework上來, Django rest framework的官網上給了一個很好用的QuickStart, 我參考Qu ......

    uj5u.com 2023-04-20 08:17:54 more
  • 記錄-new Date() 我忍你很久了!

    這里給大家分享我在網上總結出來的一些知識,希望對大家有所幫助 大家平時在開發的時候有沒被new Date()折磨過?就是它的諸多怪異的設定讓你每每用的時候,都可能不小心踩坑。造成程式意外出錯,卻一下子找不到問題出處,那叫一個煩透了…… 下面,我就列舉它的“四宗罪”及應用思考 可惡的四宗罪 1. Sa ......

    uj5u.com 2023-04-20 08:17:47 more
  • 使用Vue.js實作文字跑馬燈效果

    實作文字跑馬燈效果,首先用到 substring()截取 和 setInterval計時器 clearInterval()清除計時器 效果如下: 實作代碼如下: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta ......

    uj5u.com 2023-04-20 08:12:31 more
  • JavaScript 運算子

    JavaScript 運算子/運算子 在 JavaScript 中,有一些運算子可以使代碼更簡潔、易讀和高效。以下是一些常見的運算子: 1、可選鏈運算子(optional chaining operator) ?.是可選鏈運算子(optional chaining operator)。?. 可選鏈操 ......

    uj5u.com 2023-04-20 08:02:25 more
  • CSS—相對單位rem

    一、概述 rem是一個相對長度單位,它的單位長度取決于根標簽html的字體尺寸。rem即root em的意思,中文翻譯為根em。瀏覽器的文本尺寸一般默認為16px,即默認情況下: 1rem = 16px rem布局原理:根據CSS媒體查詢功能,更改根標簽的字體尺寸,實作rem單位隨螢屏尺寸的變化,如 ......

    uj5u.com 2023-04-20 08:02:21 more
  • 我的第一個NPM包:panghu-planebattle-esm(胖虎飛機大戰)使用說明

    好家伙,我的包終于開發完啦 歡迎使用胖虎的飛機大戰包!! 為你的主頁添加色彩 這是一個有趣的網頁小游戲包,使用canvas和js開發 使用ES6模塊化開發 效果圖如下: (覺得圖片太sb的可以自己改) 代碼已開源!! Git: https://gitee.com/tang-and-han-dynas ......

    uj5u.com 2023-04-20 08:01:50 more
  • 如何在 vue3 中使用 jsx/tsx?

    我們都知道,通常情況下我們使用 vue 大多都是用的 SFC(Signle File Component)單檔案組件模式,即一個組件就是一個檔案,但其實 Vue 也是支持使用 JSX 來撰寫組件的。這里不討論 SFC 和 JSX 的好壞,這個仁者見仁智者見智。本篇文章旨在帶領大家快速了解和使用 Vu ......

    uj5u.com 2023-04-20 08:01:37 more
  • 【Vue2.x原始碼系列06】計算屬性computed原理

    本章目標:計算屬性是如何實作的?計算屬性快取原理以及洋蔥模型的應用?在初始化Vue實體時,我們會給每個計算屬性都創建一個對應watcher,我們稱之為計算屬性watcher ......

    uj5u.com 2023-04-20 08:01:31 more
  • http1.1與http2.0

    一、http是什么 通俗來講,http就是計算機通過網路進行通信的規則,是一個基于請求與回應,無狀態的,應用層協議。常用于TCP/IP協議傳輸資料。目前任何終端之間任何一種通信方式都必須按Http協議進行,否則無法連接。tcp(三次握手,四次揮手)。 請求與回應:客戶端請求、服務端回應資料。 無狀態 ......

    uj5u.com 2023-04-20 08:01:10 more
  • http1.1與http2.0

    一、http是什么 通俗來講,http就是計算機通過網路進行通信的規則,是一個基于請求與回應,無狀態的,應用層協議。常用于TCP/IP協議傳輸資料。目前任何終端之間任何一種通信方式都必須按Http協議進行,否則無法連接。tcp(三次握手,四次揮手)。 請求與回應:客戶端請求、服務端回應資料。 無狀態 ......

    uj5u.com 2023-04-20 08:00:32 more