打开 设置-首选项-user Snippets
选择new global snippets 一个新的全局代码片段
提供的默认的案例如下:
// Example:
"Print to console": {
"scope": "javascript,typescript",
"prefix": "log",
"body": [
"console.log('$1');",
"$2"
],
"description": "Log output to console"
}
scope:表示代码作用范围,建议删掉此属性以作用全局,
prefix:设置快捷命令
body:代码内容
description:代码描述
vue3快捷代码示例:
"Print to console": {
"prefix": "vv3",
"body": [
"<template>",
"</template>",
"<script lang=\"ts\">",
"import { defineComponent } from \"vue\";",
"export default defineComponent({",
"name: 'App',",
"components: {},",
"setup() {return {}},",
"});",
"</script>",
"<style scoped></style>",
],
"description": "Log output to console"
}
代码片段文件存储在用户目录下
以window为例:C:\Users\用户\AppData\Roaming\Code\User\snippets
也可直接在用户目录下修改文件