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"
	}
}
相关推荐
:12119 小时前
idea17创建tomcat项目(计网底层核心理解!)
java·ide·intellij-idea
optimistic_chen19 小时前
【Vue3入门】Pinia 状态管理 和 ElementPlus组件库
前端·javascript·vue.js·elementui·pinia·组件
猿小猴子19 小时前
主流 AI IDE 之一的 华为云码道「CodeArts」 介绍
ide·人工智能·ai·华为云
哥本哈士奇19 小时前
Vue 3 快速入门:从零搭建前后端 CRUD 应用
前端·javascript·vue.js
SuperEugene20 小时前
Vue3 组件拆分实战规范:页面 / 业务 / 基础组件边界清晰化,高内聚低耦合落地指南|Vue 组件与模板规范篇
前端·javascript·vue.js·前端框架
还是大剑师兰特1 天前
Vue3 中的 defineExpose 完全指南
前端·javascript·vue.js
monsion1 天前
OpenCode 学习指南
人工智能·vscode·架构
xkxnq1 天前
第六阶段:Vue生态高级整合与优化(第93天)Element Plus进阶:自定义主题(变量覆盖)+ 全局配置与组件按需加载优化
前端·javascript·vue.js
A黄俊辉A1 天前
vue css中 :global的使用
前端·javascript·vue.js
非鱼䲆鱻䲜1 天前
vscode开发stm32添加新的头文件路径和包含源文件
ide·vscode·stm32·cmake·包含头文件·包含源文件