VSCODE snippets的使用
VSCODE自定义代码片段
1 F1打开控制面板,然后输入snippet
2 选择语言(这里以JavaScript为例)
3 编辑自己的代码片段
4 保存使用即可,输入prefix即可弹出自定义代码片段,如图:
个人常用snippets:
javascript:
"log snippet": { "prefix": "log", "body": [ "console.log($1)" ], "description": "log snippet" }, "for snippet": { "prefix": "for", "body": [ "for (let ${1:i} = 0; ${1:i} < ${2:dataArr}.length; ${1:i}++) {", "\tlet ${3:ele} = ${2:dataArr}[${1:i}]", "\t$0", "}" ], "description": "for snippet" }, "vm snippet": { "prefix": "vm", "body": [ "let vm = this" ], "description": "vm snippet" }
vue:
"vue snippet": { "prefix": "vue", "body": [ "<template>", "\t<div>", "\t\t$0", "\t</div>", "</template>", "<script>", "export default {", "\tdata () {", "\t\treturn {", "\t\t}", "\t},", "\tcomponents: {},", "\tmethods: {", "\t},", "\tmounted () {", "\t}", "}", "</script>", "<style scoped>", "\t", "</style>", "" ], "description": "vue snippet" }
PS: 详情、语法等参照官网链接:(有时间再补充)
https://code.visualstudio.com/docs/editor/userdefinedsnippets
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步