vscode创建vue快捷代码片段

迷南。 2022-02-03 00:55 567阅读 0赞

(1)打开 文件首选项 —> 用户代码片段

watermark_type_ZmFuZ3poZW5naGVpdGk_shadow_10_text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2NzbDEyNQ_size_16_color_FFFFFF_t_70

在搜索框搜索vue 选择vue.json文件,如果没有安装vue.json:安装插件VueHelper

(2)修改vue.json文件

  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": "vue",
  9. "body": [
  10. "<template>",
  11. " <div>\n$0",
  12. " </div>",
  13. "</template>\n",
  14. "<script>",
  15. "export default {",
  16. " props: {\n",
  17. " },",
  18. " data() {",
  19. " return {\n",
  20. " };",
  21. " },",
  22. " computed: {\n",
  23. " },",
  24. " created() {\n",
  25. " },",
  26. " mounted() {\n",
  27. " },",
  28. " watch: {\n",
  29. " },",
  30. " methods: {\n",
  31. " },",
  32. " components: {\n",
  33. " },",
  34. "};",
  35. "</script>\n",
  36. "<style lang=\"${1:scss}\" scoped>\n",
  37. "</style>\n",
  38. ],
  39. "description": "Create vue template"
  40. }
  41. }

重启vscode就可以了

在vue组件页面中输入 vue+tab键就可以快捷生成

发表评论

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

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

相关阅读

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

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