KiRaSmile
all right?

vscode创建快速生成代码模板

2020-01-10 Vscode
Word count: 356 | Reading time: 2min

点击文件->首选项->用户代码片段



新建一个新的代码片段

输入

{
    // Place your snippets for html here. Each snippet is defined under a snippet name and has a prefix, body and 
    // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
    // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the 
    // same ids are connected.
    // Example:
    // "Print to console": {
    //     "prefix": "log",
    //     "body": [
    //         "console.log('$1');",
    //         "$2"
    //     ],
    //     "description": "Log output to console"
    // }
    "Html5-Vue": {
        "prefix": "vh",
        "body": [
            "<!DOCTYPE html>",
            "<html lang=\"zh-CN\">\n",
            "<head>",
            "\t<meta charset=\"UTF-8\">",
            "\t<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">",
            "\t<meta http-equiv=\"X-UA-Compatible\" content=\"ie=edge\">",
            "\t<title>Document</title>",
            "\t<script src=\"./lib/vue-2.4.0.js\"></script>",
            "</head>\n",
            "<body>",
            "\t<div id=\"app\">$1</div>\n",
            "\t<script>",
            "\t\tvar vm = new Vue({",
            "\t\t\tel: '#app',",
            "\t\t\tdata: {},",
            "\t\t\tmethods: {}",
            "\t\t});",
            "\t</script>",
            "</body>\n",
            "</html>"
        ],
        "description": "快速创建在html5编写的vue模板"
    }
}

然后在要快速生成的文件中输入vh(prefix属性)

效果如下

Author: KiRaSmile

Link: http://yoursite.com/2020/01/10/vscode快速生成代码模板/

Copyright: All articles in this blog are licensed under CC BY-NC-SA 3.0 unless stating additionally.

NextPost >
Vue学习笔记(三)
CATALOG