vscode默认的模板可能不是自己想要的,所以我们可以自己设置一个vue的模板,方法如下:
点击左上角 文件->首选项->用户代码片段 接着会出来一个搜索框,我们输入vue 然后选择vue.json 注意不是vue-html.json
然后把里面的内容清空一下,粘贴下面的代码进去,保存关掉这个文件
{
"Print to console": {
"prefix": "vue",
"body": [
"<!---->",
"<template>",
" <div>$0</div>",
"</template>",
"",
"<script>",
"export default {",
" name:\"\",",
" data () {",
" return {",
" ",
" };",
" },",
"",
" components: {},",
"",
" computed: {},",
"",
" mounted: {},",
"",
" methods: {}",
"}",
"",
"</script>",
"<style lang='stylus' scoped>",
"",
"</style>"
],
"description": "Log output to console"
}
}
然后我们新建.vue文件时,只需要输入vue然后按回车或者tab键就直接生成一个vue的模板了,上面的代码也可以根据自己的需求来改。($0表示生成模板后光标所处的位置)