首頁>技術>

在Vue專案中需要經常建立vue檔案,所以利用Visual Studio Code的Snippets在.vue檔案建立後生成模板,就省去了做重複的工作了。

第一步

Ctrl+Shift+p 調出命令面板,輸入Snippets,開啟使用者程式碼片段設定

第二步

輸入vue並選擇,Visual Studio Code會自動生成一個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>$0</div>",			"</template>",			"",			"<script>",			"export default {",			"  components:{},",			"  data(){",			"    return {",			"    }",			"  },",			"  created(){},",			"  methods:{},",			"  watch:{},",			"  computed:{},",			"  mounted(){}",			"}",			"</script>",			"<style  scoped>",			"</style>"		],		"description": "A vue file template"	}}
最後

在新建的檔案輸入vue選擇如圖所示的程式碼片段即可

18
  • BSA-TRITC(10mg/ml) TRITC-BSA 牛血清白蛋白改性標記羅丹明
  • 大白話 linux 教程-01-linux 的發展歷史