VSCode中snippets(代码模板)的使用

首先安装Vue VSCode Snippets,在组件库中搜索并安装。

然后打开插件文件夹

文件夹名是 "作者名.vscode-插件名-版本号"组成的.

C:\Users\Administrator\.vscode\extensions\sdras.vue-vscode-snippets-3.1.1\snippets

打开vue.json

"prefix": "vbase" 就是代码块的关键词,输入vbase就会提示代码块 选择vbase2

在代码中插入以下代码:

javascript 复制代码
  "Vue Single File Component2": {
    "prefix": "vb2",
    "body": [
      "<template>",
      "\t<div>",
      "\t</div>",
      "</template>",
      "",
      "<script>",
      "export default {",
      "\t//接受父组件传过来的数据",
      "\tprops: {",
      "\t},",
      "\t//DOM组件",
      "\tcomponents: {",
      "\t},",
      "\tdata() {",
      "\t\treturn {",
      "\t\t\tproperty: 'vue test',",
      "\t\t};",
      "\t},",
      "\t//计算属性",
      "\tcomputed: {",
      "\t},",
      "\t//监听",
      "\twatched: {",
      "\t},",
      "\t//DOM在模板渲染成html前调用,即通常初始化某些属性值,然后再渲染成视图",
      "\tcreated() {",
      "\t",
      "\t},",
      "\t//DOM渲染完成,组件挂载完成",
      "\tmounted() {",
      "\t",
      "\t},",
      "\t//组件销毁",
      "\tdestroyed() {",
      "\t",
      "\t},",
      "\tmethods: {",
      "\t\tlog(str) {",
      "\t\t    console.log('log', str);",
      "\t\t}",
      "\t},",
      "}",
      "</script>",
      "",
      "<style lang=\"scss\" scoped>",
      "",
      "</style>"
    ],
    "description": "Base for VueTT File with SCSS"
  },

然后保存,重启VSCode,新建文件测试,输入vb即可,选择刚才输入的vb2即可

相关推荐
只是橘色仍温柔3 小时前
xshell可以ssh连接,但vscode不行
运维·vscode·ssh
SHtop115 小时前
Eclipse IDE
ide·eclipse
吉均6 小时前
如何实现局域网内无痛访问Jupyter Notebook?
ide·python·jupyter
A__tao7 小时前
SQL 转 PHP Eloquent、Doctrine ORM, 支持多数据库
android·ide·android studio
Tee xm16 小时前
清晰易懂的VSCode加Cline插件使用不同API提供商实现AI编程
vscode·ai编程·安装
1alisa16 小时前
Sublime Text for Mac v4【注册汉化版】代码编辑器
macos·编辑器·sublime text
神码编程17 小时前
【Unity】 HTFramework框架(六十四)SaveDataRuntime运行时保存组件参数、预制体
unity·编辑器·游戏引擎
William.csj17 小时前
Linux——开发板显示器显示不出来,vscode远程登录不进去,内存满了的解决办法
linux·vscode
mzak19 小时前
vscode集成deepseek实现辅助编程(银河麒麟系统)【详细自用版】
linux·vscode·编辑器·银河麒麟·deepseek
JCBP_19 小时前
数据结构3
服务器·c语言·数据结构·vscode