如何扩展带有类型记录的JointJs元素/链接?
我尝试过使用this.set("defaults", obj),但它被jointjs忽略了。
发布于 2016-06-17 08:50:25
JointJs有类型记录的定义文件:https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/jointjs
JointJs模型是从主干扩展而来的,因此可以在构造函数中使用this.set(key, value)表达式,除了需要编写为方法的“默认”参数。
示例:
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())
}https://stackoverflow.com/questions/37877090
复制相似问题