vscode 设置自定义vue代码片段快捷方式

第一步

打开vs-code => 文件 => 首选项 => 用户片段
在这里插入图片描述

第二步

搜索 vue.json
在这里插入图片描述
进入vue.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:
	// "Print to console": {
    
    
	// 	"prefix": "log",
	// 	"body": [
	// 		"console.log('$1');",
	// 		"$2"
	// 	],
	// 	"description": "Log output to console"
	// }
	"Print to console": {
    
    
		"prefix": "v3",
		"body": [
			"<template>",
			"",
			// "\t<div>",
			// "\t<div>",
			"</template>",
			"<script lang=\"ts\">",
			"import { defineComponent } from 'vue'",
			"export default defineComponent({",
			"\tname:'App'",
			"})",
			"</script>"

		],
		"description": "Log output to console"
	}
}

配置完成并保存

第三步

.vue文件下输入设置好的文字前缀,如上面的v3
在这里插入图片描述
出现代码块选择表示配置自定义的代码块成功!选择v3回车
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_43245095/article/details/112512948