vscode中生成vue3.0代码片段
# vscode中生成vue3.0代码片段
1、 首先在vscode编辑器中打开,【文件】–>【首选项】–>【用户片段】–>选择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"
// }
"vue3": {
"prefix": "vue3",
"body": [
"<template>",
" <div>\n",
" </div>",
"</template>\n",
"<script lang='ts'>",
"import { defineComponent,reactive, toRefs, onBeforeMount, onMounted } from 'vue';",
"import { useRoute, useRouter } from 'vue-router';",
"export default defineComponent({",
" name: 'index',",
" setup(props, context) {",
" const route = useRoute();",
" const router = useRouter();",
" console.log('1-开始创建组件-setup')",
" const state = reactive({\n",
" })",
" const funcList = {",
" getInfo() {}",
" }",
" onBeforeMount(() => {",
" console.log('2.组件挂载页面之前执行----onBeforeMount')",
" })",
" onMounted(() => {",
" funcList.getInfo();",
" console.log('3.-组件挂载到页面之后执行-------onMounted')",
" })",
" return {",
" ...toRefs(state),",
" ...funcList",
" }",
" },",
"}",
"</script>",
"<style scoped lang='scss'>\n",
"</style>",
],
"description": "Log output to console"
}
}
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
2、新建.vue结尾的文件,输入vue3 有提示,生成片段
编辑 (opens new window)
上次更新: 2024/01/26, 05:03:22
- 01
- python使用生成器读取大文件-500g09-24
- 02
- Windows环境下 Docker Desktop 安装 Nginx04-10
- 03
- 使用nginx部署多个前端项目(三种方式)04-10