第一步
打开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
回车