前端

VSCode新建vue文件自定义模板

2017-09-18  本文已影响1978人  飞奔的阿加西
飞奔的阿加西.jpg

背景

每次新建一个vue文件!都要重行敲打一遍template。script。style。神烦!有没有和别的编辑器一样!设置自己默认的模板!

解决

有的!前提VSCode安装了vetur

image.png

-把下面的代码片段放入里面

// 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"
    },
    "Create vue template": {
        "prefix": "vue",
        "body": [
            "<template>",
            "</template>",
            "<script>",
            "export default {",
            "  name: \"${1:component_name}\",",
            "  data () {",
            "    return {",
            "    };",
            "  }",
            "}",
            "</script>",
            "<style lang=\"${2:scss}\" scoped>",
            "</style>"
        ],
        "description": "Create vue template"
    }
image.png

VSCode版本号:1.16.1
系统:windows10

上一篇 下一篇

猜你喜欢

热点阅读