https://snippet-generator.app/
{
// Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. 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": {
// "prefix": "log",
// "body": [
// "console.log('$1');",
// "$2"
// ],
// "description": "Log output to console"
// }
"OA callapi": {
"prefix": "oacallapi",
"body": [
"callAPI(\"${1:XXXXX.API}\", {",
" ${2:}",
"}, function (res) {",
" ${3:}",
"",
"}, \"json\")"
],
"description": "OA callapi"
},
"OA接口写法": {
"prefix": "trycatchOAAPI",
"body": [
"try {",
"",
" $1",
"",
"} catch (e) {",
" return {",
" code: 400,",
" msg: e.message",
" }",
"}",
""
],
"description": "OA接口写法"
},
"OAservice写法": {
"prefix": "serviceOA",
"body": [
"get$1: function ({$2}) {",
" return this.request({",
" apiName: 'get$1',",
" data: {",
" $2",
" }",
" })",
" },"
],
"description": "OAservice写法"
},
"DMMapi": {
"prefix": "dmmapi",
"body": [
"/**",
" * ${1:apiName}接口",
" * 传值:",
" * ${2:INPUT_DATA}",
" */",
"",
"try {",
"",
" if (typeof ${2:INPUT_DATA} == \"undefined\") {",
" return {",
" code: 401,",
" msg: \"${2:INPUT_DATA} require.\"",
" }",
" }",
"",
" var exec = null;",
"",
"} catch (e) {",
" return {",
" code: 400,",
" msg: JSON.stringify(e.message)",
" }",
"}"
],
"description": "DMMapi"
},
"类写法": {
"prefix": "dblclass",
"body": [
"/**",
" * ${1:Parent}类",
" */",
"",
"var ${1:Parent}= function (",
" ${2:name}",
") {",
" this.${2:name} = ${2:name}",
"}",
"",
"// 共有属性,对应模型",
"${1:Parent}.prototype.${3:sex} = \"\";",
"",
"// 共有方法",
"${1:Parent}.prototype.${4:speak}= function () {",
" // todo sth.",
"}",
"",
"// 虚函数",
"${1:Parent}.prototype.${5:setName}= function () {",
" throw new Error('${5:setName} must implemented')",
"}",
"",
""
],
"description": "类写法"
},
"类写法-继承": {
"prefix": "dblclassextends",
"body": [
"/**",
" * ${1:child} 类",
" */",
"var ${1:child}= function () {",
" // ${2:Parent}.call(this); super",
"}",
"",
"// ${1:child} extends ${2:Parent}.",
"${1:child}.__proto__ = ${2:Parent}"
],
"description": "类写法-继承"
},
"继承公式": {
"prefix": "dblextends",
"body": [
"var prototype = Object.create(${1:ParentClass}.prototype);",
"prototype.constructor = ${2:ChildClass};",
"${2:ChildClass}.prototype = prototype;"
],
"description": "继承公式"
},
"dmmImport": {
"prefix": "dmmimport",
"body": [
"eval(`try{",
" ${getAPI(\"${1}\")}",
" }catch(e){",
" print(e.message);",
" }`);"
],
"description": "dmmImport"
},
"trycatchtransactiondmmapi": {
"prefix": "trycatchtransaction",
"body": [
"try {",
"",
" startTransaction();",
" ${1}",
"",
"} catch (e) {",
" rollback();",
"",
"} finally {",
" endTransaction();",
"}"
],
"description": "trycatchtransactiondmmapi"
}
}