https://code.visualstudio.com/docs/editor/userdefinedsnippets
文件→首选项→用户片段
{
// Place your 全局 snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
"Print to console": {
"scope": "javascript,typescript",
"prefix": "log",
"body": [
"console.log('$1');",
// "$2"
],
"description": "Log output to console"
},
"Print to vuetemplate": {
"prefix": "vuetemplate",
"body": [
"<template>",
"\t<div class=''>\n\t\t$2\n\t</div>",
"</template>",
"",
"<script>",
"\t//import { projectClassList } from '@/api/project/projectclass';",
"\texport default {",
"\t\tname: '',",
"\t\tcomponents: {},",
"\t\tdata () {",
"\t\t\treturn {",
"\t\t\t\tqueryParams: {",
"\t\t\t\t\t\tpageNum: 1,",
"\t\t\t\t\t\tpageSize: 10,",
"\t\t\t\t},",
"\t\t\t};",
"\t\t},",
"\t\tcreated(){},",
"\t\tmethods: {},",
"\t}",
"</script>",
"",
"<style lang='scss' scoped>",
"//@import url($3)",
"",
"</style>"
],
"description": "vue output to vue-template"
},
"Print to rules": {
"scope": "javascript,typescript",
"prefix": "rules",
"body": [
"rules: {",
"\t\troleName: [",
"\t\t\t\t{ required: true, message:\"角色名称不能为空\", trigger: \"blur\" },",
"\t\t],",
"},"
],
"description": "Print rules"
},
"Print to filters": {
"scope": "javascript,typescript",
"prefix": "filters:gcz",
"body": [
"filters: {",
"\tverifyStatusFilter(value) {",
"\t\tif (value === 1) {",
"\t\t\t\treturn '审核通过';",
"\t\t} else {",
"\t\t\t\treturn '未审核';",
"\t\t}",
"\t},",
"},"
],
"description": "Print rules"
},
}
转载请注明:有爱前端 » VisualStudioCode代码片段