1

mxCell 的 id 默认使用整数类型,每次递增 1,但我们希望将其替换为 UUID 类型。覆盖默认功能的更好方法是什么?谢谢

mxGraphModel.prototype.createId = function(cell)
{
    var id = this.nextId;
    this.nextId++;

    return this.prefix + id + this.postfix;
};

上面的方法我已经改了,但是不确定是否会影响mxGraph中的其他模块。

mxGraphModel.prototype.createId = function(cell)
{
    var id = myUtils.getUUID()     //a method to return an UUID

    return this.prefix + id + this.postfix;
};
4

1 回答 1

1

没关系,只要生成的数字是唯一的。实际值是多少并不重要。

如果您的意图是对所有mxGraphModel实例都进行覆盖,那么覆盖原型也很好。

于 2017-05-09T08:05:33.610 回答