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"
	}
}
相关推荐
化作繁星30 分钟前
在 Vue 3 中,如何缓存和复用动态组件
前端·vue.js·缓存
一只小姜丝3321 小时前
解决各大浏览器中http地址无权限调用麦克风摄像头问题
网络·vue.js·网络协议·http
技术咖啡馆C1 小时前
二、IDE集成DeepSeek保姆级教学(使用篇)
ide·ai编程·idea-plugin·deepseek
林的快手4 小时前
CSS默认样式
前端·css·vue.js·chrome·css3
林涧泣8 小时前
【Uniapp-Vue3】开发userStore用户所需的相关操作
前端·vue.js·uni-app
皓月当空hy10 小时前
vue3中测试:单元测试、组件测试、端到端测试
vue.js
码上飞扬10 小时前
Vue.js组件开发:从基础到进阶
vue.js
昨日余光11 小时前
仅需三分钟,使用Vue3.x版本组件式风格实现一个消息提示组件!
前端·javascript·css·vue.js·typescript·html
新时代丘鸣山12 小时前
Idea java项目结构介绍
java·ide·intellij-idea
Long_poem14 小时前
【自学笔记】Vue基础知识点总览-持续更新
前端·vue.js·笔记