VS code 设置vue文件模版

进入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, 再按回车,即生成模版内容
在这里插入图片描述
在这里插入图片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章