VSCode snippets 自定义Vue3代码片段(持续更新)

在编写Vue代码时发现VSCode中的各类snippets插件无法提供一些常用的代码片段,为避免重复造轮子,提高编码效率,特意自己定义了一些代码片段。为方便初学者,提供了自定义代码片断的方法。

一、 自定义代码片断的方法

1.打开命令面板(Ctrl+Shift+P)
VSCode snippets 自定义Vue3代码片段(持续更新)_第1张图片
2. 输入 user Snippets,点击配置用户代码片段
在这里插入图片描述
3. 新建全局代码片段文件,并给文件命名(如mysnippets)
VSCode snippets 自定义Vue3代码片段(持续更新)_第2张图片
4. 复制下方代码,替换掉文件中的内容

2. VSCode Vue3自定义代码片段

{
	
	//fn-> 标准函数格式
	" standard function": {
		"scope": "javascript,typescript",
		"prefix": "fn",
		"body": [
			"function ${1:name}(${2:params}){"
			"    $3"
			"}"
		],
		"description": "xgx's function"
	},

	// impr-> 从vue中导入reactive
	"import { reactive } from 'vue';": {
		"prefix": "impr",
		"body": [
		  "import { reactive } from 'vue';"
		],
		"description": "import { reactive } from 'vue';"
	},

	// impv-> 从vue中导入...
	"import { } from 'vue';": {
		"prefix": "impv",
		"body": [
		  "import { $1 } from 'vue';"
		],
		"description": "import { } from 'vue';"
	},

	// livfor->  
  • 标签中的v-for "li v-for": { "prefix": "livfor", "body": [ "
  • ", " {{ ${3:item} }}", "
  • "
    ], "description": "li v-for" } }

    你可能感兴趣的:(VSCode(Visual,Studio,Code),vscode,ide,编辑器,代码片段,snippets,自定义代码片段的方法)