VSCode 使用代码片段快捷生成 Vue3 模板

Web

习惯了 Webstorm 快捷的代码模板,而 VSCode 默认是没有 Vue3 代码模板的,无法愉快的食用 Vue3,那就扒贴自己创建一个模板!

创建模板:

  1. 界面右上角「文件」-> 「首选项」-> 「配置用户代码片段」-> 「新建全局代码片段文件」-> 键入vue3.json 回车。

  2. 进行一个copy,具体模板自由发挥。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{
// 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": "vue3",
"body": [
"<template>",
" <div></div>",
"</template>",
"",
"<script setup lang='ts'>",
"$1",
"</script>",
"",
"<style scoped lang='stylus'>",
"</style>"
],
"description": "Log output to console"
}
}

使用方法:

  1. 新建 vue 文件。

  2. 在编辑区中键入 vue3 后回车即可。

本文作者:Kiro

本文链接: https://www.kiro.cc/2022/06/vue3-log/