我正在尝试将以下 JavaScript 代码迁移到 TypeScript。
var DemoGroupStyle = yfiles.lang.Class('DemoGroupStyle',{
'$extends': yfiles.styles.NodeStyleBase,
'constructor': function() {
yfiles.styles.NodeStyleBase.call(this);
},
/**
* Backing field for below property
* @type {string}
*/
'$cssClass': "",
/**
* Gets or sets a custom css class that is assigned to the top level element representing the node.
* @type {string}
*/
'cssClass': {
'$meta': function() {
return [
yfiles.graphml.GraphMLAttribute().init({'defaultValue' : ""}),
yfiles.lang.TypeAttribute(yfiles.lang.String.$class)];
},
'get': function() {
return this.$cssClass;
},
'set': function(/**string*/ value) {
this.$cssClass = value;
}
},
我尝试了以下逻辑:
cssClass: string = "";
metacssClass() {
return [new yfiles.graphml.GraphMLAttribute().defaultValue = "", new yfiles.lang.TypeAttribute(yfiles.lang.String.$class)];
}
getcssClass() {return this.cssClass;};
setcssClass(value) {this.cssClass = value};
但如果我想用它代替它,它就不起作用。
你能告诉我为什么我的逻辑是错误的,我该如何改变它?