blogger

JackS·Zhao

人生就像开车在路上走,你我只是其中的一个驾驶员。送走老的、迎来小的,匆匆看过路边风景。一直向前行驶,却不知道是谁修的这条路。
Code在vue文件中输入vue创建基础模版

时间:2023-10-14    作者:JackS·Zhao    分类: 编程


打开Code→文件→首选项→配置用户代码片段→这时会弹出一个搜索框 输入vue
第一个会出现vue.json 打开文件 出现下面的代码

{
    // Place your snippets for vue 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"
    // }
}

将下面代码写入vue.json中

    "Print to console": {
        "prefix": "vue",
        "body": [
         "<template>",
                  " <div>\n",
                  " </div>",
                  "</template>\n",
                  "<script>",
                  " export default {",
                  "   data () {",
                  "     return {\n",
                  "     }",
                  "   },",
                  "   methods: {\n",
                  "   }",
                  " }",
                  "</script>\n",
                  "<style scoped>\n",
                  " ",
                  "</style>",
                  "$2"
        ],
        "description": "Log output to console"
       }

写完如下:

{
    // Place your snippets for vue 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"
    // }
    "Print to console": {
        "prefix": "vue",
        "body": [
         "<template>",
                  " <div>\n",
                  " </div>",
                  "</template>\n",
                  "<script>",
                  " export default {",
                  "   data () {",
                  "     return {\n",
                  "     }",
                  "   },",
                  "   methods: {\n",
                  "   }",
                  " }",
                  "</script>\n",
                  "<style scoped>\n",
                  " ",
                  "</style>",
                  "$2"
        ],
        "description": "Log output to console"
       }
}

OK 保存, 你在你的项目中新建一个.vue文件然后输入vue 后Enter回车就会出现基础框架代码。