外观
编辑器支持
为了方便开发,我们针对 Visual Studio Code 专门编写了一些代码片段(snippet),可以用于加速开发。这些代码片段定义在 .vscode/*.code-snippets
文件中,用 VS Code 打开项目时,编辑器会自动读取这些代码片段。之后你就可以通过键盘输入 prefix
字段定义的前缀,来触发对应的代码片段。
提示
你可以参考现有的例子自行添加其他代码片段定义。定义规则如下:
scope
:指定代码片段的作用范围,例如typescript
、javascript
等。若同时支持多个作用范围,用英文逗号隔开。prefix
:指定代码片段的触发前缀,例如createTableIfNotExist
。description
:指定代码片段的描述,例如Create table if not exist
。body
:指定代码片段的内容,支持变量替换。
示例:
json
{
"Print to console": {
"scope": "javascript,typescript",
"prefix": "log",
"body": ["console.log('$1');", "$2"],
"description": "Log output to console"
}
}
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
预置的代码片段
createTableIfNotExist
:创建数据库表(如果不存在)