VSCode - 前端代码块大法

2023-03-28  本文已影响0人  刘_小_二

实操方法

VsCode配置前端的代码块具体步骤如下:

【准备文件】 前端代码块配置文件内容。

1.生成前端代码块配置内容

在线生成工具snippet语法结构

2.VsCode配置

【菜单选项】文件 - 首选项 - 配置用户代码片段

【MacOS 菜单选项】顶部Code - 首选项 - 配置用户代码片段

[图片上传失败...(image-2ba88-1680077890953)]

1.按照提示选择全局||项目的代码块,输入名称。

2.输入名称回撤后,会生成页面;

{
   // 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"
   // }
   
   // 直接粘贴之前代码块配置文件,即可
   "Print5 to console": {
       "prefix": "vue",
       "body": [
           "<!-- 文件名:'$TM_FILENAME_BASE'-->",
           "<!-- 当前文档的完整文件路径:'$TM_FILEPATH'-->",
           "<template>",
           "\t<div>",
           "\t</div>",
           "</template>",
           "<script lang=\"ts\" setup>",
           "</script>",
           "<style lang=\"scss\">",
           "</style>"
       ],
       "description": "Log output to console"
   }
}

3.粘贴保存即可。

4.具体使用
[图片上传失败...(image-fe49be-1680077890953)]

上一篇 下一篇

猜你喜欢

热点阅读