vscode新建vue3文件模板


输入快捷新建的名字

enter 确认后在文件中输入以下内容

html 复制代码
{
  // 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 $1></div>",
      "</template>",
      "",
      "<script setup>",
      "import { ref, reactive, toRefs, onBeforeMount, onMounted, watchEffect, computed } from 'vue';",
      "import { useStore } from 'vuex';",
      "import { useRoute, useRouter } from 'vue-router';",
      "/**",
      "* 仓库",
      "*/",
      "const store = useStore();",
      "/**",
      "* 路由对象",
      "*/",
      "const route = useRoute();",
      "/**",
      "* 路由实例",
      "*/",
      "const router = useRouter();",
      "//console.log('1-开始创建组件-setup')",
      "/**",
      "* 数据部分",
      "*/",
      "const data = reactive({})",
      "onBeforeMount(() => {",
      "  //console.log('2.组件挂载页面之前执行----onBeforeMount')",
      "})",
      "onMounted(() => {",
      "  //console.log('3.-组件挂载到页面之后执行-------onMounted')",
      "})",
      "watchEffect(()=>{",
      "})",
      "// 使用toRefs解构",
      "// let { } = { ...toRefs(data) } ",
      "defineExpose({",
      "  ...toRefs(data)",
      "})",
      "",
      "</script>",
      "<style scoped lang='scss'>",
      "</style>"
    ],
    "description": "Log output to console"
  }
}

使用

在.vue 文件输入vue3(新建时输入的名字), 按enter就可以新建好模板

相关推荐
Irene199117 分钟前
Vue3 中使用的命名规则 和 实际开发命名规范总结
vue.js·命名规范
Amumu121382 小时前
Vue脚手架(二)
前端·javascript·vue.js
比特森林探险记3 小时前
组件通信 与 ⏳ 生命周期
前端·javascript·vue.js
海绵宝龙3 小时前
Vue中nextTick
前端·javascript·vue.js
qq_12498707535 小时前
基于springboot的会议室预订系统设计与实现(源码+论文+部署+安装)
java·vue.js·spring boot·后端·信息可视化·毕业设计·计算机毕业设计
ttod_qzstudio6 小时前
Vue 3 中 toRaw 的取舍之道:以 Babylon.js 3D 开发为例
vue.js·babylonjs
Mr Xu_7 小时前
Vue3 + Element Plus 实战:App 版本管理后台——动态生成下载二维码与封装文件上传
前端·javascript·vue.js
比特森林探险记7 小时前
Vue基础语法与响应式系统详解
前端·javascript·vue.js
你知道“铁甲小宝”吗丶8 小时前
VSCode使用Claude Code
vscode·ai·ai编程
zihan03218 小时前
element-plus, el-table 表头按照指定字段升降序的功能实现
前端·vue.js·状态模式