1. 程式人生 > >在VSCode中,建立一個.vue檔案的模板

在VSCode中,建立一個.vue檔案的模板

具體步驟

1、使用Ctrl + Shift + P召喚出控制檯,然後輸入snippets並回車。

2、接下來輸入vue並選擇,VSCode會自動生成一個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"
		}
	*/
	"Print to console": {
		"prefix": "vue",
		"body": [
			"<template>",
			"  <div class=\"myDiv\">$0</div>",
			"</template>",
			"",
			"<script>",
			"export default {",
			"  components:{},",
			"  props:{},",
			"  data(){",
			"    return {",
			"    }",
			"  },",
			"  watch:{},",
			"  computed:{},",
			"  methods:{},",
			"  created(){},",
			"  mounted(){}",
			"}",
			"</script>",
			"<style lang=\"scss\" scoped>",
			".myDiv{}",
			"</style>"
		],
		"description": "A vue file template"
	}
}

3、這樣我們的模板就建好了

4、建立一個.vue檔案 輸入vue 然後回車就出來模板了