vscode——配置用户代码片段

黄粱一梦2024-11-270

1.设置代码片段

左下角找到用户设置,点击代码片段

image.png

2.选择全局/局部代码片段

这里我设置的是局部的vue代码片段,大家可根据自身需要来进行设置.

image.png

单代码片段设置

{
		"vue3-ts片段": {
		  "prefix": "vue3-ts",
		  "body": [
			"<script setup lang=\"ts\">",
			"import { ref, reactive, toRefs, onMounted} from 'vue'",
			"",
			"</script>",
			"",
			"<template>",
			"  <div></div>",
			"</template>",
			"",
			"<style scoped lang=\"scss\">",
			"</style>",
		],
		  "description": "Log output to console"
		}
}

设置多行代码片段

只需要在原来的基础上面,再扩展一个对象

:::danger
需要注意,如果自己定义的对象名称和前面的一致会进行覆盖
:::

{
		"vue3-ts片段": {
		  "prefix": "vue3-ts",
		  "body": [
			"<script setup lang=\"ts\">",
			"import { ref, reactive, toRefs, onMounted} from 'vue'",
			"",
			"</script>",
			"",
			"<template>",
			"  <div></div>",
			"</template>",
			"",
			"<style scoped lang=\"scss\">",
			"</style>",
		],
		  "description": "Log output to console"
		},
		"vue3-js片段": {
			"prefix": "vue3-js",
			"body": [
			  "<script setup lang=\"js\">",
			  "import { ref, reactive, toRefs, onMounted} from 'vue'",
			  "",
			  "</script>",
			  "",
			  "<template>",
			  "  <div></div>",
			  "</template>",
			  "",
			  "<style scoped lang=\"scss\">",
			  "</style>",
		  ],
			"description": "Log output to console"
		  },
"[自定义名称]": {
			"prefix": "vue3-js",
			"body": [
			  "<script setup lang=\"js\">",
			  "import { ref, reactive, toRefs, onMounted} from 'vue'",
			  "",
			  "</script>",
			  "",
			  "<template>",
			  "  <div></div>",
			  "</template>",
			  "",
			  "<style scoped lang=\"scss\">",
			  "</style>",
		  ],
			"description": "Log output to console"
		  },
}

使用自定义代码片段

image.png

image.png

分类:随笔

标签:随笔工具

上一篇注册Google账号时用中国大陆手机号无法验证的解决办法下一篇Vue3+echarts5踩坑,resize方法报错

版权声明

本文系作者 @黄粱一梦 转载请注明出处,文中若有转载的以及参考文章地址也需注明。\(^o^)/~

Preview