VSCode 在HTML中自定义vue模板的实现
作者:互联网
位置:在Vscode中找到 设置 -> 用户代码片段,在输入框内输入html,并点击第一个html.json。
复制以下代码:
{ // Place your snippets for html 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": [ "<div id=\"app\">", "\t{{message}}", "</div>\n", "<script src=\"../js/vue.js\"></script>", "<script>", " //创建Vue实例,得到 ViewModel", " const app = new Vue({", "\tel: '#app',", "\tdata: {", "\t\tmessage: '${1:hello}',", "\t},", "\tmethods: {", "\t\t", "\t}", " });", "</script>", ], "description": "a vue template" // 模板的描述 } }
转义字符解释:
\t \" \n都是转义字符,而空格就是单纯的空格,输入时可以输入空格
\t 的意思是 横向跳到下一制表符位置 等于 Tab键
\" 的意思是 双引号
\n 的意思是回车换行
$1代表着光标,它的位置即光标的默认位置,可以有多个光标:$2,$3,$4等
标签:body,vue,console,自定义,VSCode,snippet,prefix,html 来源: https://www.cnblogs.com/essayblog/p/15245213.html