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, 再按回車,即生成模版內容
在這裏插入圖片描述
在這裏插入圖片描述

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