• vscode新建vue3文件模板


    在这里插入图片描述
    在这里插入图片描述
    输入快捷新建的名字
    在这里插入图片描述
    enter 确认后在文件中输入以下内容

    {
      // 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"
      }
    }
    
    
    • 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
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64

    使用
    在.vue 文件输入vue3(新建时输入的名字), 按enter就可以新建好模板
    在这里插入图片描述

  • 相关阅读:
    uni-app实现支付及项目打包上传
    【常用代码14】el-input输入框内判断正则,只能输入数字,过滤汉字+字母。
    CentOS安装openjdk和elasticsearch
    Linux之内核定时器
    libc和glibc有什么区别
    电商通用(四)
    直播视频录制技巧,分享2个实用的方法
    网络安全(黑客)—-2024自学手册
    手部数据太难找?最全手部开源数据集分享
    06:HAL----定时器
  • 原文地址:https://blog.csdn.net/qq_45021462/article/details/132673503