vscode 快速新建.vue模板

1.文件 ==> 首選項 ==> 用戶代碼片段 ==> 輸入 vue,選擇 vue.json ==> 編輯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": [
			"<!--",
			"	*404頁面",
			"-->"
            "<template>",
            "    <div id=\"\">\n",
            "    </div>",
            "</template>\n",
            "<script>",
            "export default {",
            "    data() {",
            "        return {}",
			"    },",
			"",
			"	activated(){",
			"",
			"	},",
			"",
			"	created(){"
			"",
			"	},",
			"",
			"	mounted(){",
			"",
			"	},",
			"",
			"	computed(){",
			"",
			"	},",
			"	methods:{",
			"",
			"	},",
			"",
			"	filters:{",
			"",
			"	},",
			"",
			"	watch:{",
			"",
			"	},",
			"",
			"	//離開路由,不可截停",
			"	destroyed(){",
			"",
			"	},",
			"",
			"	//離開路由,可截停",
			"	beforeRouteLeave(to, from, next){",
			"		next();",
			"	},",

            "}",
            "</script>\n",
            "<style lang=\"less\" scoped>",
			"@import url();",
			"</style>",
        ],
        "description": "Log output to console"
    }
}

2.文件 ==> 首選項 ==> 設置 ==> 新增這2項

// 讓vscode允許自定義的代碼片段提示出來
"editor.snippetSuggestions": "top",
"editor.formatOnPaste": true,

3.新建.vue文件,輸入vue,按下tab鍵即可。本人親測可用,非常方便

發佈了14 篇原創文章 · 獲贊 1 · 訪問量 1萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章