我正在尝试创建一个允许我创建 JS 构造函数的简单片段。到目前为止,我所拥有的是
"class constructor": {
"prefix": "class",
"body": [
"class ${1:ClassName} {",
"\t\tconstructor({${2:thisName}: ${2}}) {",
"\t\t\tthis.${2} = ${2}",
"\t}",
"}"
],
"description": "class constructor template"
},
这按预期工作,但我想看看是否可以添加多个条目,这也this
为$2{thisName}
. 我希望的是能够添加多个键值对。
因此,而不是结束于:
class ClassName {
constructor({ thisName: thisName}) {
this. thisName = thisName
}
}
我希望能够添加其他项目,使其看起来像;this.another = another
自动创建新行的位置。
class ClassName {
constructor({ thisName: thisName, another: another}) {
this. thisName = thisName
this.another = another // this is create
}
}
在这里${3}..
不起作用,因为可能有任何数量的项目。