【发布时间】:2014-05-28 09:19:31
【问题描述】:
我有一个 MVC 应用程序,我在我的一个视图中使用 KineticJS。我想知道如果我要从组中并最终从数据库中删除形状或图像,使用哪种方法更好。是destroy() 还是remove()?
【问题讨论】:
标签: javascript canvas kineticjs
我有一个 MVC 应用程序,我在我的一个视图中使用 KineticJS。我想知道如果我要从组中并最终从数据库中删除形状或图像,使用哪种方法更好。是destroy() 还是remove()?
【问题讨论】:
标签: javascript canvas kineticjs
使用 remove,您可以从画布中删除一个节点,但如果您愿意,您可以稍后再次使用它。 使用destroy,节点会被完全销毁,不能重用。
所以,如果你想完全删除一个元素,使用destroy,否则使用remove。
【讨论】:
这是下面的源代码.... destroy() 看起来它调用了 remove() 不是吗?所以基本上它们是多余的?
remove: function () {
var c = this.getParent();
return c && c.children && (c.children.splice(this.index, 1), c._setChildrenIndices(), delete this.parent), this._clearSelfAndDescendantCache(q), this._clearSelfAndDescendantCache(b), this._clearSelfAndDescendantCache(t), this._clearSelfAndDescendantCache(j), this._clearSelfAndDescendantCache(a), this
},
destroy: function () {
Kinetic._removeId(this.getId()), Kinetic._removeName(this.getName(), this._id), this.remove()
},
【讨论】: