打开VS code,“文件-首选项-用户代码片段-选择新建全局代码片段文件 “
属性介绍:prefix 就是你自定义的快捷键
body 就是你自定义的代码片段
description 就是这段代码的注释
demo :
{
"Print to console": {
"prefix": "nodes",
"body": [
"const http = require(‘http‘)",
"const server = http.createServer()",
"server.on(‘request‘, (req, res) => {",
" console.log(‘我是node服务器‘)",
"$1",
"})",
"server.listen(3000, () => {",
" console.log(‘server running at http://127.0.0.1:3000‘);",
"})"
],
"description": "node 服务器"
}
}
原文地址:https://www.cnblogs.com/famensaodiseng/p/10499624.html
时间: 2024-10-10 15:42:17