vscode 设置code模板

  1. 选择  文件 > 首选项 > 用户代码片段

  2. 选择你需要自定义模板的文件,以vue为例
  3. 配置对应文件json
    把代码片段写在json里。每个代码段都是在一个代码片段名称下定义的,并且有prefix、body和description。prefix是用来
    触发代码片段的。使用 $1,$2 等指定光标位置,这些数字指定了光标跳转的顺序,$0表示最终光标位置。
     
    {
      "vue-template": {
        "prefix": "vue",
        "body": [
          "<template>",
          "  <div class=\"$1\">",
          "",
          "  </div>",
          "</template>",
          "",
          "<script>",
          "export default {",
          "  name: '$1',",
          "  data() { ",
          "    return {",
          "",
          "    }",
          "  }",
          " }",
          "</script>",
          "",
          "<style lang=\"\" scoped>",
          "  .$1{",
          "",
          "  }",
          "</style>"
    
        ],
        "description": "my vue template"
      }
    }
    

猜你喜欢

转载自blog.csdn.net/Y17868877685/article/details/89430185
今日推荐