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即可

相关推荐
小灰灰__1 小时前
IDEA加载通义灵码插件及使用指南
java·ide·intellij-idea
Mortal_hhh2 小时前
VScode的C/C++点击转到定义,不是跳转定义而是跳转声明怎么办?(内附详细做法)
ide·vscode·stm32·编辑器
无极程序员2 小时前
PHP常量
android·ide·android studio
小黄人软件5 小时前
android浏览器源码 可输入地址或关键词搜索 android studio 2024 可开发可改地址
android·ide·android studio
叶知安9 小时前
如何用pycharm连接sagemath?
ide·python·pycharm
电子云与长程纠缠11 小时前
UE5.3中通过编辑器工具创建大纲菜单文件夹
java·ue5·编辑器
会发光的猪。11 小时前
如何在vscode中安装git详细新手教程
前端·ide·git·vscode
lucky九年12 小时前
vscode翻译插件
ide·vscode·编辑器
帅得不敢出门12 小时前
Gradle命令编译Android Studio工程项目并签名
android·ide·android studio·gradlew