gpt4 book ai didi

javascript - mxGraph可以使用UUID将默认生成的id替换为整数类型吗?

转载 作者:太空宇宙 更新时间:2023-11-04 15:41:09 25 4
gpt4 key购买 nike

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;
};

最佳答案

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

如果您打算对所有 mxGraphModel 实例执行此操作,则覆盖原型(prototype)也可以。

关于javascript - mxGraph可以使用UUID将默认生成的id替换为整数类型吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43861716/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com