目标:新建html快捷键
解说:当我们想在VSCode中新建html代码时,可以 输入vh 然后回车或者Tab即可自动生成一个html文件模板
步骤:
1.点击设置-----用户代码片段----搜索html,出现html.json文件,点击即可;
2.
{ "h5 template": { "prefix": "vh", "body": [ "<!DOCTYPE html>", "<html lang="en">", "<head>", " <meta charset="UTF-8">", " <meta name="viewport" content="width=device-width, initial-scale=1.0">", " <meta http-equiv="X-UA-Compatible" content="ie=edge">", " <title>Document</title>", " <script src="./lib/vue-2.4.0.js"></script>", "</head> ", "<body>", " <div id ="app"> </div> ", " <script>", " //创建Vue实例,得到 ViewModel", " var vm = new Vue({", " el: '#app',", " data: {},", " methods: {}", " });", " </script>", "</body> ", "</html>" ], "description": "HT-H5" //模板的描述 } }
3.转移字符串解释
"
都是转义字符,而空格就是单纯的空格,输入时可以输入空格
的意思是 横向跳到下一制表符位置 等于 Tab键
" 的意思是 双引号
的意思是回车换行
4.在新建html文件夹中输入vh-----tab/enter 即可设置成功