https://snippet-generator.app/

  1. {
  2. // Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and
  3. // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
  4. // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
  5. // same ids are connected.
  6. // Example:
  7. // "Print to console": {
  8. // "prefix": "log",
  9. // "body": [
  10. // "console.log('$1');",
  11. // "$2"
  12. // ],
  13. // "description": "Log output to console"
  14. // }
  15. "OA callapi": {
  16. "prefix": "oacallapi",
  17. "body": [
  18. "callAPI(\"${1:XXXXX.API}\", {",
  19. " ${2:}",
  20. "}, function (res) {",
  21. " ${3:}",
  22. "",
  23. "}, \"json\")"
  24. ],
  25. "description": "OA callapi"
  26. },
  27. "OA接口写法": {
  28. "prefix": "trycatchOAAPI",
  29. "body": [
  30. "try {",
  31. "",
  32. " $1",
  33. "",
  34. "} catch (e) {",
  35. " return {",
  36. " code: 400,",
  37. " msg: e.message",
  38. " }",
  39. "}",
  40. ""
  41. ],
  42. "description": "OA接口写法"
  43. },
  44. "OAservice写法": {
  45. "prefix": "serviceOA",
  46. "body": [
  47. "get$1: function ({$2}) {",
  48. " return this.request({",
  49. " apiName: 'get$1',",
  50. " data: {",
  51. " $2",
  52. " }",
  53. " })",
  54. " },"
  55. ],
  56. "description": "OAservice写法"
  57. },
  58. "DMMapi": {
  59. "prefix": "dmmapi",
  60. "body": [
  61. "/**",
  62. " * ${1:apiName}接口",
  63. " * 传值:",
  64. " * ${2:INPUT_DATA}",
  65. " */",
  66. "",
  67. "try {",
  68. "",
  69. " if (typeof ${2:INPUT_DATA} == \"undefined\") {",
  70. " return {",
  71. " code: 401,",
  72. " msg: \"${2:INPUT_DATA} require.\"",
  73. " }",
  74. " }",
  75. "",
  76. " var exec = null;",
  77. "",
  78. "} catch (e) {",
  79. " return {",
  80. " code: 400,",
  81. " msg: JSON.stringify(e.message)",
  82. " }",
  83. "}"
  84. ],
  85. "description": "DMMapi"
  86. },
  87. "类写法": {
  88. "prefix": "dblclass",
  89. "body": [
  90. "/**",
  91. " * ${1:Parent}类",
  92. " */",
  93. "",
  94. "var ${1:Parent}= function (",
  95. " ${2:name}",
  96. ") {",
  97. " this.${2:name} = ${2:name}",
  98. "}",
  99. "",
  100. "// 共有属性,对应模型",
  101. "${1:Parent}.prototype.${3:sex} = \"\";",
  102. "",
  103. "// 共有方法",
  104. "${1:Parent}.prototype.${4:speak}= function () {",
  105. " // todo sth.",
  106. "}",
  107. "",
  108. "// 虚函数",
  109. "${1:Parent}.prototype.${5:setName}= function () {",
  110. " throw new Error('${5:setName} must implemented')",
  111. "}",
  112. "",
  113. ""
  114. ],
  115. "description": "类写法"
  116. },
  117. "类写法-继承": {
  118. "prefix": "dblclassextends",
  119. "body": [
  120. "/**",
  121. " * ${1:child} 类",
  122. " */",
  123. "var ${1:child}= function () {",
  124. " // ${2:Parent}.call(this); super",
  125. "}",
  126. "",
  127. "// ${1:child} extends ${2:Parent}.",
  128. "${1:child}.__proto__ = ${2:Parent}"
  129. ],
  130. "description": "类写法-继承"
  131. },
  132. "继承公式": {
  133. "prefix": "dblextends",
  134. "body": [
  135. "var prototype = Object.create(${1:ParentClass}.prototype);",
  136. "prototype.constructor = ${2:ChildClass};",
  137. "${2:ChildClass}.prototype = prototype;"
  138. ],
  139. "description": "继承公式"
  140. },
  141. "dmmImport": {
  142. "prefix": "dmmimport",
  143. "body": [
  144. "eval(`try{",
  145. " ${getAPI(\"${1}\")}",
  146. " }catch(e){",
  147. " print(e.message);",
  148. " }`);"
  149. ],
  150. "description": "dmmImport"
  151. },
  152. "trycatchtransactiondmmapi": {
  153. "prefix": "trycatchtransaction",
  154. "body": [
  155. "try {",
  156. "",
  157. " startTransaction();",
  158. " ${1}",
  159. "",
  160. "} catch (e) {",
  161. " rollback();",
  162. "",
  163. "} finally {",
  164. " endTransaction();",
  165. "}"
  166. ],
  167. "description": "trycatchtransactiondmmapi"
  168. }
  169. }