使用vue3时,volar并没有给默认的vue文件生成模板,只能在vscode新建:
- 设置-新建代码片段,输入vue,回车
- 复制如下内容,保存:
{
// 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.
"vue3": {
"prefix": "vue3",
"body": [
"<template>",
" <!-- vue3页面 -->",
" <div> </div>",
"</template>\n",
"<script lang='ts'>",
"import { defineComponent, reactive } from 'vue'",
"export default defineComponent({",
" name: 'App',",
" setup() {",
" return {}",
" }",
"})",
"</script>\n",
"<style scoped>",
"</style>"
]
}
}