VSCode - 前端代碼塊大法

實操方法

VsCode配置前端的代碼塊具體步驟如下:

【準備文件】 前端代碼塊配置文件內(nèi)容。

1.生成前端代碼塊配置內(nèi)容

在線生成工具snippet語法結(jié)構

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)]

?著作權歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容