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"
	}
}
相关推荐
小胖红4 小时前
Xcode 打包失败 处理
ide·macos·xcode
1024小神9 小时前
Vscode/Cursor中的Prettier插件格式化降级操作
ide·vscode·编辑器
xixixin_9 小时前
【vue】中字符串与数组转换:为何首选 Computed 而非 Methods?
前端·javascript·vue.js
i_am_a_div_日积月累_9 小时前
el-drawer注册全局点击事件无效;el-dialog注册全局点击事件无效
javascript·vue.js·elementui
跃渊Yuey9 小时前
【Linux】Linux进程信号产生和保存
linux·c语言·c++·vscode
啥都不懂的小小白10 小时前
Vue第四篇:组件通信 + DOM 更新 + 过渡动画
vue.js·全局事件通信
向下的大树10 小时前
VUE父子组件传参中的触发时机问题:异步场景下的解决方案
前端·javascript·vue.js
英俊潇洒美少年10 小时前
vue2中使用节流防抖函数时,使用的vue状态始终是初始化的数据
前端·javascript·vue.js
1024002410 小时前
vscode无法选择conda虚拟环境下的解释器
ide·vscode·conda
刘一说10 小时前
Vue3响应式原理重构:从Object.defineProperty到Proxy的革命性升级
javascript·vue.js·重构