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 小时前
【PPTist】添加PPT模版
前端·学习·编辑器·html
热爱生活的五柒2 小时前
vscode利用ofExtensions插件可以调试单进程Openfoam,但是不能调试mpi多进程案例
ide·vscode·编辑器
小陈phd2 小时前
Vscode LinuxC++环境配置
linux·c++·vscode
界面开发小八哥2 小时前
更高效的Java 23开发,IntelliJ IDEA助力全面升级
java·开发语言·ide·intellij-idea·开发工具
小江村儿的文杰10 小时前
XCode Build时遇到 .entitlements could not be opened 的问题
ide·macos·ue4·xcode
为什么每天的风都这么大11 小时前
Vscode/Code-server无网环境安装通义灵码
ide·vscode·阿里云·编辑器·ai编程·code-server
ahadee14 小时前
蓝桥杯每日真题 - 第19天
c语言·vscode·算法·蓝桥杯
芝麻团坚果17 小时前
对subprocess启动的子进程使用VSCode python debugger
linux·ide·python·subprocess·vscode debugger
写点什么啦17 小时前
[debug]不同的window连接ubuntu的vscode后无法正常加载kernel
linux·vscode·ubuntu·debug
小码ssim18 小时前
IDEA使用tips(LTS✍)
java·ide·intellij-idea