vscode设置代码模板

一键生成vue3模板代码

效果演示

输入vue3 显示快捷键 按回车键 一键生成自定义模板

实现方法

  1. 进入用户代码片段设置
  2. 选择片段语言 vue.json
  3. 输入自定义的代码片段
    prefix是触发的内容,按自己的喜好来就行;
    body是模板代码,写入自己需要的就行
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:
	"create vue3 template": {
        "prefix": "vue3",  
        "body": [
          "<template>",
          "  <div class=\"$1\">$2</div>",
          "</template>",
          "",
          "<script setup>",
          "import { ref, reactive } from 'vue'",
         
          "</script>",
          "<style  lang='scss' scoped>",
          "$4",
          "</style>"
        ],
        "description": "create vue3 template"
      },
      
    }

完成!!


一键生成css样式

效果演示

实现方法

  1. 同上
  2. 选择你使用的语言,例如css、scss

3. 输入自定义代码,我这里是设置brr快捷键是border: 1px solid red;

json 复制代码
{
	// Place your snippets for scss 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:
	"set a border": {
		"prefix": "brr",
		"body": [
			"border: 1px solid red;",
			"$2"
		],
		"description": "set a border"
	}
}

一键输出console.log('$1');

效果演示

实现方法

  1. 同上
  2. 选择javascript.json
  3. 写入代码
json 复制代码
{
	// Place your snippets for javascript 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": "cl",
		"body": [
			"console.log('$1');",
			"$2"
		],
		"description": "Log output to console"
	}
}
相关推荐
独泪了无痕5 小时前
viewer.js 安装与配置指南:实现图片预览功能
前端·vue.js
csdn_aspnet13 小时前
2026 年 9 款最佳开源 AI 编码助手及常见问题解答
vscode·continue·cline·goose·ai编码·aider·opencode
lemon_yyds13 小时前
uVIew2 弹框滚动穿透问题-[uu-popup ]组件
vue.js
超爱吃香菜的菜鸟14 小时前
关于pnpm 部分使用(一)
前端·vue.js
任逍遥201115 小时前
免费!VS Code 行为树编辑器 micBT:行为树生成、编辑、推演、调试
vscode·行为树·vscode插件·micbt
林三的日常17 小时前
【无标题】
java·spring boot·vscode·调试·后端开发
Super 含17 小时前
Android 包体积优化(一):APK 到底大在哪里?从 APK 结构到体积分析
android·ide·vscode
冷雨夜中漫步17 小时前
IDEA CodeStyle代码风格格式化模板
java·ide·intellij-idea
jingchao199819 小时前
Cannot read properties of null (reading ‘insertBefore‘)
前端·javascript·vue.js
Promising_GEO19 小时前
新电脑科研环境配置指南:Miniforge + PyCharm + GitHub 从安装到可用
ide·python·pycharm·github·地理