Home > Development Tools > VSCode > body text

How to set up vscode template

Release: 2020-01-11 09:35:48
Original
2678 people have browsed it

How to set up vscode template

vscode设置模版的方法:

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

How to set up vscode template

选择你需要自定义模板的文件,以vue为例

How to set up vscode template

配置对应文件json

把代码片段写在json里。每个代码段都是在一个代码片段名称下定义的,并且有prefix、body和description。prefix是用来

触发代码片段的。使用 $1,$2 等指定光标位置,这些数字指定了光标跳转的顺序,$0表示最终光标位置。

{
  "vue-template": {
    "prefix": "vue",
    "body": [
      "<template>",
      "  <div class=\"$1\">",
      "",
      "  </div>",
      "</template>",
      "",
      "<script>",
      "export default {",
      "  name: &#39;$1&#39;,",
      "  data() { ",
      "    return {",
      "",
      "    }",
      "  }",
      " }",
      "</script>",
      "",
      "<style lang=\"\" scoped>",
      "  .$1{",
      "",
      "  }",
      "</style>"
 
    ],
    "description": "my vue template"
  }
}
Copy after login

相关文章教程推荐:vscode教程

The above is the detailed content of How to set up vscode template. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template