目标:
我们希望每次新建.vue文件后,VSCODE能够根据配置,自动生成我们想要的内容。
方法:
打开VSCODE编辑器,依次选择“文件 -> 首选项 -> 用户代码片段”,此时,会弹出一个搜索框,我们输入vue, 如下:
选择vue后,VSCODE会自动打开一个名字为vue.json的文件,复制以下内容到这个文件中:
{
"Print to console": {
"prefix": "vue",
"body": [
"<template>",
" <div></div>",
"</template>",
"",
"<script>",
"export default {",
" data () {",
" return {",
" };",
" },",
"",
" components: {},",
"",
" computed: {},",
"",
" mounted() {},",
"",
" methods: {}",
"}",
"",
"</script>",
"<style lang='less' scoped>",
"</style>"
],
"description": "Log output to console"
}
}
保存后关闭这个文件。