VSCode设置代码块(Snippets),快捷初始化vue模板

本文用作记录设置Vue Snippets,快捷初始化vue模板(适用于Mac版VSCode,Windows待尝试)。

一、使用User Snippet

Code -> Preference -> User Snippets -> New (global) Snippets (可选当前文件和全局配置),复制以下配置,保存。
使用:”prefix“值为快捷方式,适用.vue后缀的文件。以下为用作初始化vue模板的例子,也可根据此格式自定义代码块。

{
	"Print to console": {
		"prefix": "vue",
		"body": [
			"",
			"",
			"",
			"",
			""
			""
		],
		"description": "Log output to console"
	}
	//  Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and 
	//  description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope 
	//  is left empty or omitted, the snippet gets applied to all languages. 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": {
	//  	"scope": "javascript,typescript",
	//  	"prefix": "log",
	//  	"body": [
	//  		"console.log('$1');",
	//  		"$2"
	//  	],
	//  	"description": "Log output to console"
	//  }
}

二、使用VSCode插件

快捷初始化vue模板,推荐使用此方法。缺点:不支持自定义代码块,只可用做初始化vue模板。
安装VSCode插件:vue init biaov。vue文件中输入‘init’,回车即可。

参考:https://blog.csdn.net/lei_0912/article/details/98867087 (侵删)

你可能感兴趣的:(Vue,vue.js)