vscode 快速创建vue2!3模板


一、新建模板配置文件vue.json

有三个方法,用哪个都行:

  1. 使用快捷Ctrl + Shift + P唤出控制台,然后输入snippets并选择,输入 vue.json ,然后 enter 回车;
  2. 文件>首选项>用户代码片断里面,输入 vue.json ,然后 enter 回车;
  3. file > Preferences > User Snippets,当弹出搜索框之后,输入 vue.json ,然后 enter 回车;

二、删除默认代码,替换代码

三、更改模板内容

vue.json文件替换以下模板内容(复制当前代码粘贴上去(当前配置的是 vue2/3 模版,当然也可以自定义自己想要的模版)

{
  // Place your 全局 snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
  // description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
  // is left empty or omitted, the snippet gets applied to all languages. 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:
  "vue-template3": {
    "prefix": "vue3",
    "body": [
      // "<!--",
      // "  *@author [前端_XXX]", // 作者名称
      // "  *@date $CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",//当前时间
      // "!-->",
      "<template>",
      "  <div>",
      "",
      "  </div>",
      "</template>",
      "<script setup lang=\"ts\">",
      "import { ref, reactive } from 'vue'",
      "",
      "</script>",
      "<style lang=\"scss\" scoped>",
      "",
      "</style>"
    ],
    "description": "vue-template3"
  },
  "vue-template2": {
    "prefix": "vue2",
    "body": [
      // "<!--",
      // "  *@author [前端_XXX]", // 作者名称
      // "  *@date $CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE $CURRENT_HOUR:$CURRENT_MINUTE:$CURRENT_SECOND",//当前时间
      // "!-->",
      "<template>",
      "  <div>",
      "",
      "  </div>",
      "</template>",
      "<script>",
      "export default {",
      "  data () {",
      "    return {",
      "",
      "    }",
      "  }",
      "}",
      "</script>",
      "<style lang=\"scss\" scoped>",
      "",
      "</style>"
    ],
    "description": "vue-template2"
  }
}

四、模板使用

新建一个 test.vue 文件,输入“<font style="color:rgb(79, 79, 79);background-color:rgb(238, 240, 244);">vue2 或 </font>[vue3](https://so.csdn.net/so/search?q=vue3&spm=1001.2101.3001.7020)”,按下回车键或者Tab键,模板就自动生成了。


文章作者:   leader755
版权声明:   本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 leader755 !
评论
 上一篇
又拍云CDN加速网站(自主源和云存储) 又拍云CDN加速网站(自主源和云存储)
域名接入(自有源)如果您的网站或应用使用的是自有源站或者第三方存储源,您可以通过自主源的方式接入 CDN 服务。此时您的源站无需做任何改动,只需要走完下面的配置流程并在 DNS 解析商处修改 CNAME 记录即可享受 CDN 服务,具体操作
2025-01-05
下一篇 
8.watchEffect高级侦听器 8.watchEffect高级侦听器
watchEffect 立即执行传入的一个函数,同时响应式追踪其依赖,并在其依赖变更时重新运行该函数。 如果用到 message 就只会监听 message 就是用到几个监听几个 而且是非惰性,且会默认调用一次 let message
2024-08-31
  目录