自己写了一些根据自己习惯弄成的自定义代码片段,不喜跳过

很简单,快速过一下,F1,然后输入 snippets

VSCode 如何操作用户自定义代码片段

 

 vue代码片段

{
    // 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"
    // },
    "doc for vue": {
        "prefix": "vue",
        "body": [
            "<template>",
            "    <div>",
            "        ${1:标题}",
            "    </div>",
            "</template>",
            
            "<script>",
            "    export default{",
            "        data(){",
            "            return{",
            "    ${2}",
            "            }",
            "        },",
            "        created() {//在实例创建完成后被立即调用",
            "    ${2}",
            "        },",
            "        methods:{",
            "    ${2}",
            "        }",
            "    }",
            "</script>",
            "<style lang=\"scss\" scoped>",
            "    ${2}",
            "</style>"
        ],
        "description": "快速生成vue"
    },
    "doc for vue父组件": {
        "prefix": "vue父组件",
        "body": [
            "<template>",
            "    <div>",
            "        ${1:标题}",
            "    </div>",
            "</template>",
            
            "<script>",
            "    //1.0导入 xx 组件",
            "    import xxx from '路径'",
            "    export default{",
            "        data(){",
            "            return{",
            "    ${2}",
            "            }",
            "        },",
            "        created() {//在实例创建完成后被立即调用",
            "    ${2}",
            "        },",
            "        methods:{",
            "    ${2}",
            "        },",
            "        components:{//1.1 注册 xx 子组件",
            "    ${2}",
            "        }",
            "    }",
            "</script>",
            "<style lang=\"scss\" scoped>",
            "    ${2}",
            "</style>"
        ],
        "description": "vue使用父组件模板"
    },
    "doc for vue子组件": {
        "prefix": "vue子组件",
        "body": [
            "<template>",
            "    <div>",
            "        ${1:标题}",
            "    </div>",
            "</template>",
            
            "<script>",
            "    export default{",
            "        data(){",
            "            return{",
            "    ${2}",
            "            }",
            "        },",
            "        created() {//在实例创建完成后被立即调用",
            "    ${2}",
            "        },",
            "        methods:{",
            "    ${2}",
            "        },",
            "        props:['xx']//接收父组件传的值",
            "    }",
            "</script>",
            "<style lang=\"scss\" scoped>",
            "    ${2}",
            "</style>"
        ],
        "description": "vue使用子组件模板"
    },
}
View Code

相关文章: