在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選擇如圖所示的程式碼片段即可
最新評論
相關內容
- 有將Visual Studio IDE/Code部署到自己的伺服器的解決方案嗎?
- 使用者為何投訴微軟Visual Studio Code“聖誕帽”圖示?
- Visual Studio Code安裝教程?
- Visual Studio Code如何關閉程式碼智慧提示?
- visual studio code怎麼執行python程式碼?
- Visual Studio Code圖示發生變動了嗎?
- 微軟為何將Visual Studio Online更名為Codespaces?
- Visual Studio 2008怎麼設定啟動窗體?
- Visual Studio 2013詳細安裝教程(安裝+註冊)?
- visual studio的串列埠控制元件怎麼使用?