VSCode自定义代码片段(模板)
想要快捷的在VSCode里生成自定义的代码片段,进行如下设置:
打开 File-> Preference->User Snippets
出现选项
选择 html.json
即可
在此 JSON
配置文件里书写将要展示的代码片段及其快捷键
以下就是一个 Vue HTML 文件的模板,快捷键是 vh
{
"vh": {
"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>",
" var vm=new Vue({",
" el:'#app',",
" data:{},",
" methods:{}",
" });",
" </script>",
"</body>",
"",
"</html>",
],
"description": "vh components"
}
}
设置完毕后按 vh + tab 就可快速生成代码片段了.
没有修不好的电脑