我们希望每次新建.vue文件后,VSCODE能够根据配置,自动生成我们想要的代码片段
- 参考文章 https://blog.csdn.net/silencejude/article/details/81748714
使用vscode建立vue模板
- 1 打开VSCODE编辑器 依次选择“文件 -> 首选项 -> 用户代码片段”,此时,会弹出一个搜索框,我们输入vue会出现一个vue.json
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
32{
"Print to console": {
"prefix": "vue",
"body": [
"<!-- $0 -->",
"<template>",
" <div></div>",
"</template>",
"",
"<script>",
"export default {",
" data () {",
" return {",
" };",
" },",
"",
" components: {},",
"",
" computed: {},",
"",
" mounted: {},",
"",
" methods: {}",
"}",
"",
"</script>",
"<style lang='scss' scoped>",
"</style>"
],
"description": "Log output to console"
}
} - 2 保存后关闭这个文件,在创建的.vue文件中输入vue然后按回车键即可