星五博客

vscode用户片段

文件》首选项》用户片段》vue.json
设置后,新建文件,扩展名为vue的,在文件内输入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"
// }
"Print to console": {
"prefix": "cons",
"body": [
"console.log(\"$1\")"
],
"description": ""
},
"print to vue": {
"prefix": "vue",
"body": [
"<!-- $1 -->",
"<template>",
" <div class=\"$2\"></div>",
"</template>",
"",
"<script>",
"import { createApp } from 'vue'",
"const app = createApp();",
"export default {",
"  name: '$3',",
"  components: {},",
"  props: {},",
"  data () {",
"    return {",
"    }",
"  },",
"  computed: {},",
"  watch: {},",
"  created () {},",
"  mounted () {},",
"  methods: {",
"  }",
"}",
"",
"</script>",
"",
"<style lang='less' scoped>",
"",
"</style>",
""
],
"description": ""
}
}

Vue