如何在VSCode中设置console.log快捷键 以及vue html代码块

console.log在我们的日常开发中是使用频率特别高的一句代码,那我们怎样在编译器中快速的打出来呢。其实很简单只要两步就行

1. 在VScode中打开文件 → 首选项 → 用户代码片段 → 在搜索框中搜索 JavaScript 选择 JavaScript.json
2. 然后我们在其中添加这样一段代码就好了

"Print to console": {
        "prefix": "cl",  // 也可以设置其他你习惯的快捷键.
        "body": [
            "console.log('$1');",
        ],
        "description": "Log output to console"
    }

接下来我们只要在平时使用时输入 cl +Tab 键就能快速打出 console.log()了。

 

vue html代码块设置

新建或修改vue.json

 

 

在打开的页面加入一下代码

 

 注意直接加到中括号内    内容可以自行更改

 "Print to console": {
        "prefix": "vue",
        "body": [
            "<template>",
            "    <div>\n",
            "    </div>",
            "</template>\n",
            "<script>",
            "export default {",
            "    data() {",
            "        return {\n",
            "        };",
            "    },",
            "    created() {\n",
            "    },",
            "    mounted() {\n",
            "    },",
            "    methods: {\n",
            "    }",
            "};",
            "</script>\n",
            "<style scoped lang=\"${1:less}\">\n",
            "</style>\n",
        ],
        "description": "Create vue template"
    }

 

posted @ 2021-06-17 10:44  ComeIntoBud  阅读(609)  评论(0)    收藏  举报