Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $YECBGYFECGEAFWHA as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2

Deprecated: imwpcache\f884414bce24ee67f\f73723ec7b1919fa5::__construct(): Implicitly marking parameter $BBWFDDBHHYHDXXAB as nullable is deprecated, the explicit nullable type must be used instead in /www/wwwroot/www.chuangxiangniao.com/wp-content/plugins/imwpcache-dist/build/f884414bce24ee67ff73723ec7b1919fa5.php on line 2
聊聊vscode中如何配置vue文件自定义模板_创想鸟

聊聊vscode中如何配置vue文件自定义模板

本篇文章给大家介绍vscode中vue文件自定义模板的方法。有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助。

聊聊vscode中如何配置vue文件自定义模板

具体步骤

1、文件 –> 首选项 –> 用户片段

1.png

在输入框输入vue(如果要设置其他文件的模板,也可以输入其他文件)【推荐学习:《vscode教程》】

立即学习“前端免费学习笔记(深入)”;

2、选择Vue(vue)

编辑器自动打开了一份vue.json文件

2.png

3、根据自己的需求,在”Print to console”里如何自己的模板要求,例子如下:

代码小浣熊 代码小浣熊

代码小浣熊是基于商汤大语言模型的软件智能研发助手,覆盖软件需求分析、架构设计、代码编写、软件测试等环节

代码小浣熊 396 查看详情 代码小浣熊

{    // 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"    // }    "vue": {        "prefix": "vue",        "body": [            "",            "  $0",            "\n",            "\n",            "export default {",            "  name: '',\n",            "  components: {},\n",            "  data() {",            "    return {}",            "  },\n",            "  created() {},\n",            "  methods: {},\n",            "}\n",            "\n",            "",            "",        ],        "description": "This is a simple vue template"    }}

prefix: 表示生成自定义模板的命令(vue)body:自定义模板,每行为数组里的一个元素$0: 表示生成模板后光标的所在位置description: 自定义模板的描述

4、保存vue.json 文件

5、新建一个vue文件,输入vue,按回车就可生成刚刚设置好的自定义模板

3.png

最终的模板:

4.png

那问题来了如果我要设置多个自定义模板呢?

这个也很简单,只有在刚设置好的vue.json里,在写多一个模板就行了,如下:

{    "vue": {        "prefix": "vue",        "body": [            "",            "  $0",            "\n",            "\n",            "export default {",            "  name: '',\n",            "  components: {},\n",            "  data() {",            "    return {}",            "  },\n",            "  created() {},\n",            "  methods: {},\n",            "}\n",            "\n",            "",            "",        ],        "description": "This is a simple vue template"    },    "vue2": {        "prefix": "vue2",        "body": [            "",            "  $0",            "\n",            "\n",            "export default {",            "  name: '',\n",            "  props: {},\n",            "  data() {",            "    return {}",            "  },\n",            "  created() {},\n",            "  methods: {},\n",            "}\n",            "\n",            "",            "",        ],        "description": "This is a simple vue template"    },}

更多编程相关知识,请访问:编程视频!!

以上就是聊聊vscode中如何配置vue文件自定义模板的详细内容,更多请关注创想鸟其它相关文章!

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 chuangxiangniao@163.com 举报,一经查实,本站将立刻删除。
发布者:程序猿,转转请注明出处:https://www.chuangxiangniao.com/p/825594.html

赞 (0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
怎么调节夸克浏览器亮度 夸克浏览器亮度怎么调节方法
上一篇 2025年11月27日 05:19:25
Linux缓存策略怎样优化网站
下一篇 2025年11月27日 05:19:26

相关推荐

发表回复

登录后才能评论
关注微信