vscode 代码段 配置代码片段 snippets

如何在 vscode 配置代码片段?

ctrl + shift + p 命令面板,输入 user,找到 user snippets,选择 new global snippets file,输入名称,开始编写。
{
    "Print to console": {
        "prefix": "log",
        "body": [
            "console.log('$1');"
        ],
        "description": "Log output to console"
    },
    "Vue模板": {
        "prefix": "vue-template vue.init",
        "body": [
          "<template>",
          "  <section class=\"$TM_FILENAME_BASE\">",
          "   $CURRENT_YEAR/$CURRENT_MONTH/$CURRENT_DATE $1",
          "  </section>",
          "</template>\n",
          "<script>",
          "export default {",
          " name: '$TM_FILENAME_BASE',",
          "  data() {",
          "    return {\n",
          "    }",
          "  },",
          "  components: {},",
          "  watch: {},",
          "  mounted() {},",
          "  methods: {}",
          "}",
          "</script>\n",
          "<style scoped lang=\"less\">\n",
          "</style>",
          "$0"
        ],
        "description": "Vue模板"
      }
}
原文地址:https://www.cnblogs.com/CyLee/p/15660510.html