Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vscode自定义代码段 #7

Open
hezizi opened this issue Apr 24, 2018 · 0 comments

Comments

@hezizi
Copy link
Owner

@hezizi hezizi commented Apr 24, 2018

提高开发效率,这些你必须要会

注意:创建哪种语言的代码片段就进相应语言的代码片段区域,写js代码段就不要把代码段写在了php的代码段编写区

JavaScript代码段

{  
    "Print to vue": {  
        "prefix":"vue",  
        "body": [  
            "new Vue({\r\n\tel:'#app',\r\n\tdata:{\r\n\t\t$2\r\n\t},\r\n})",  
        ],  
        "description":"script中的vue"  
    },  
} 

效果:

image

vue代码段

{  
    "Print to vue": {  
        "prefix": "vue",  
        "body": [  
            "<template>\r\n\t$1\r\n</template>\r\n\r\n<script>\r\n\texport default {\r\n\t\tdata() {\r\n\t\t\treturn {\r\n\t\t\t\t\r\n\t\t\t}\r\n\t\t},\r\n\t}\r\n</script>\r\n\r\n<style scoped>\r\n\t$3\r\n</style>"  
        ],  
        "description": "vue文件的初始代码段"  
    },  
}

效果:

image

还有一种更为直观的写法,更容易书写:

双引号需要在前面加上 \ 进行转义

"Print to js": {  
    "prefix": "js",  
    "body": [  
        "<script src=\"https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js\"></script>",  
        "<script>",  
            "\t$(function() {",  
                "\t\t$1",  
            "\t})",  
        "</script>"  
    ],  
    "description": "Log output to js"  
},
"Print to jsvue": {  
    "prefix": "jsvue",  
    "body": [  
        "<div id=\"app\"></div>",  
        "<script src=\"https://cdn.bootcss.com/vue/2.5.16/vue.min.js\"></script>",  
        "<script>",  
            "\tnew Vue({",  
                "\t\tel: 'app',",  
                "\t\tdata: {",  
                    "\t\t\t$1",  
                "\t\t}",  
            "\t})",  
        "</script>"  
    ],  
    "description": "Log output to jsvue"  
}, 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.