vscode代码模板(vue3模板)输入vue3显示代码提示

朱雀 2024-03-23 16:01 215阅读 0赞

途径一:在vscode中依次打开:【文件】—>【首选项】—>【配置用户代码片段】—>【新代码片段】

途径二:或者点击左下角的设置模样的按钮也可找到(如下图)

265f5fdcd4c54e70b43906ea9eae0b1a.png

然后点击vue.jsone376b6d6b8f348ee940ecaa8ac33ffad.png

如果没设置过的话就像下图一样;配置过的应该也知道后面的步骤了

6377a5bc8610419ea90ae0425182088b.png

贴入下面代码

  1. {
  2. // Place your snippets for vue here. Each snippet is defined under a snippet name and has a prefix, body and
  3. // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
  4. // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
  5. // same ids are connected.
  6. // Example:
  7. // "Print to console": {
  8. // "prefix": "log", //log为快捷名称
  9. // "body": [
  10. // "console.log('$1');",//body中就是输入快捷名称并且选择时快捷生成的代码模板
  11. // "$2"
  12. // ],
  13. // "description": "Log output to console"
  14. // }
  15. "Print to console": {
  16. "prefix": "vue3",
  17. "body": [
  18. "<template>",
  19. " <div></div>",
  20. "</template>",
  21. "",
  22. "<script setup>",
  23. "import { ref, reactive, getCurrentInstance } from 'vue';",
  24. "const { proxy } = getCurrentInstance()",
  25. "</script>",
  26. "",
  27. "<style scoped lang='scss'>",
  28. "</style>"
  29. ],
  30. "description": "Log output to console"
  31. }
  32. }

快捷键:ctrl+s;保存好文件就可以用了

87ee8ff93d9345eda2821446c3e84613.png

当我们选择vue3时就可快速生成代码模板body中的代码了,如下图

874f85faeeac496bb57a69bb0bfbfddb.png

就此完成;

只为记录学习中的问题

发表评论

表情:
评论列表 (有 0 条评论,215人围观)

还没有评论,来说两句吧...

相关阅读

    相关 使用VSCode创建代码模板快捷输入

    使用VSCode创建代码模板快捷输入 在编程过程中,我们经常需要编写一些重复的代码,例如函数定义、循环结构等。为了提高效率,我们可以利用VSCode的代码模板功能来创建快捷输