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"
	}
}
相关推荐
程序员爱德华6 分钟前
VSCode git/gerrit解冲突
git·vscode·gerrit
徐小超21 分钟前
从0到1落地AI知识问答系统(一):AI结对协作实战技巧
vue.js·node.js·全栈
摇滚侠13 小时前
SpringBoot3+Vue3 全套视频教程 45-51
前端·javascript·vue.js
疏狂难除14 小时前
JetBrains IDE插件开发教程(五)——File Header
ide·kotlin
星河耀银海15 小时前
框架结合:Vue+HTML5+AI实现智能前端应用开发
前端·vue.js·html5
英勇无比的消炎药15 小时前
还在手写对话面板?TinyRobot Container 一个组件装下整个 AI 聊天
vue.js
不甘平凡的小鸟16 小时前
Element-UI记录
javascript·vue.js·ui·elementui
用户29307509766916 小时前
流式输出:Vue 3 + DeepSeek API 实战
vue.js
先吃饱再说16 小时前
流式输出完全指南:让 AI 对话像打字机一样流畅
javascript·vue.js
OpenTiny社区18 小时前
TinyEngine 2.11 重磅更新!AI 深度嵌入画布,Vue 项目一键转换成 DSL
前端·vue.js·人工智能·ai编程·opentiny·tinyengine