添加 vscode 自定义代码块
以vue为例
一、打开vscode>文件>首选项>用户片段>vue.json.code
二、编写代码块, 其中一行一句;
$1是占位符,就是你可以输入的地方。
"Print to console": { "scope": "javascript,typescript", "prefix": "con", //快捷键 "body": [ "console.log('$1');", //显示的代码块 "$2" ], "description": "Log output to console" }, "new Vue": { "scope": "javascript,typescript", "prefix": "vv", "body": [ "new Vue({", //每一行都需要用""包裹 " el:'#root',", " data:{", " ", " }", "})", "$2" ], "description": "Log output to console" }
三、保存之后,打开任意vue文件输入 gg 就可以在提示框里看到,选中回车。