在用户代码片段中新建文件,属于自己的个性化快捷代码
VSCode配置路径:file(文件) => preferences(首选项) => user snippets(用户片段) 新建vue.json,粘贴如下内容
{
"Vue3快速生成模板": {
"prefix": "vue3",
"body": [
"<template>",
"<div></div>",
"</template>",
"<script lang='ts'>",
"import { defineComponent, reactive, toRefs } from 'vue-demi';",
"import { useI18n } from '/@/hooks/web/useI18n';",
"export default defineComponent({",
"name: 'ComponentName',",
"components: {},",
"props: {",
"name: {",
"type: String,",
"default: '',",
"},",
"},",
"emits: ['success'],",
"setup(props, { emit }) {",
"const { t } = useI18n();",
"const data = reactive({});",
"function Init() {",
"emit('success');",
"}",
"return {",
"...toRefs(data),",
"t,",
"Init,",
"};",
"},",
"});",
"</script>",
"<style scoped lang='less'></style>"
],
"description": "Log output to console"
}
}
保存之后,新建vue文件,输入vue3,TAB键 即可快速生成你想要的结构。