如何使用打字稿扩展 JointJs elements/links
How to extend JointJs elements/links with typescript
如何使用打字稿扩展 JointJs elements/links?
我试过this.set("defaults", obj)
,但是被jointjs忽略了
JointJs 有 typescript 的定义文件:https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/jointjs
JointJs模型是从Backbone扩展而来的,所以可以在构造函数中使用this.set(key, value)
表达式,除了"defaults"参数,需要写成方法。
示例:
class MyType extends joint.shapes.basic.Rect {
constructor(attributes?: any, options?: any) {
super(attributes, options);
this.set("markup", "<rect/>");
}
defaults(): Backbone.ObjectHash {
return joint.util.deepSupplement({...}, joint.shapes.basic.Rect.prototype.defaults);
}
}
在 MyType
的子类中可以使用 super.defaults()
:
defaults(): Backbone.ObjectHash {
return joint.util.deepSupplement({...}, super.defaults())
}
如何使用打字稿扩展 JointJs elements/links?
我试过this.set("defaults", obj)
,但是被jointjs忽略了
JointJs 有 typescript 的定义文件:https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/jointjs
JointJs模型是从Backbone扩展而来的,所以可以在构造函数中使用this.set(key, value)
表达式,除了"defaults"参数,需要写成方法。
示例:
class MyType extends joint.shapes.basic.Rect {
constructor(attributes?: any, options?: any) {
super(attributes, options);
this.set("markup", "<rect/>");
}
defaults(): Backbone.ObjectHash {
return joint.util.deepSupplement({...}, joint.shapes.basic.Rect.prototype.defaults);
}
}
在 MyType
的子类中可以使用 super.defaults()
:
defaults(): Backbone.ObjectHash {
return joint.util.deepSupplement({...}, super.defaults())
}