實操方法
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)]