進入User Snippets
方法一: File --> Preferences --> User Snippets
方法二:左下角齒輪 —> User Snippets
進入設置
在User Snippets
裏輸入vue
, 選擇 vue.json
(有的vscode 版本是vue),進入vue.json
進行配置
詳細配置如下所示
{
// 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"
// }
"vue template":{
"prefix":"vue",
"body":[
"<template>",
"<div ></div>",
"</template>",
"<script>",
"export default {",
"name:'$1',",
"filters:{},",
"components: {},",
"mixins:[],",
"data() {",
"return {}",
"},",
"computed: {},",
"watch: {},",
"beforeCreate() {},",
"created() {",
"},",
"beforeMount() {},",
"mounted() {",
"},",
"beforeUpdate() {},",
"updated() {}, ",
"beforeDestroy() {},",
"destroyed() {},",
"activated() {},",
"methods: {}",
"}",
"</script>",
"<style lang='scss' scoped>",
"</style>"
],
"description": "vue template"
}
}
使用
在新建的vue文件裏,輸入 vue, 再按回車,即生成模版內容