vscode自动生成模版name默认为文件名mac版

一.code -- 首选项 -- 用户片段

二.cmd+p打开搜索面板搜索vue.json,点击打开

三. 最后全文复制就好啦!  戳这里

        {

    // Place your snippets for vue here. Each snippet is defined under a snippet name and has a prefix, body and

    // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:

    // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the

    // same ids are connected.

    // Example:

    // "Print to console": {

    //  "prefix": "log",

    //  "body": [

    //      "console.log('$1');",

    //      "$2"

    //  ],

    //  "description": "Log output to console"

    // }

    "Print vue model": {

            "prefix": "vue",

            "body": [

                "<template>",

                "  <div>$1",

                "  </div>",

                "</template>\n",

                "<script>",

                "export default {",

                "  name:'$TM_FILENAME_BASE',",   

                "  data() {",

                "    return {\n",

                "    }",

                "  },",

                "  components: {",

                "  }",

                "}",

                "</script>\n",

                "<style lang=\"scss\">",

                "</style>",

                "$2"

            ],

            "description": "my vue model"

        }

}


注:1.其中的$1, $2 是快速生成后光标位置,先位于$1,按下Tab键后位于$2 

2.自动生成name的秘诀就在$TM_FILENAME_BASE,详戳这里

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。