JointJS提供了从图形(如dia.Link.prototype.disconnect和dia.Link.prototype.remove )中删除链接的方法。
但是,它们首先依赖于对链接对象的访问。是否有任何方法通过ID查询链接对象的JointJS图(joint.dia.Graph)?
我可以手动维护从ID到链接对象的JS映射,但这听起来很乏味。
发布于 2017-03-03 00:05:54
如果您希望访问任何链接,则可以删除两个选项。
_.each(cellView.paper.model.getLinks(), function(link) {
console.log(link.id, link.get('source'), link.get('target'))
})
OR
_.each(cellView.paper.model.get('cells'), function(cell) {
if (cell instanceof joint.dia.Link) {
// cell is a link
console.log(cell.id, cell.get('source'), cell.get('target'))
} else {
// cell is an element
console.log(cell.id, cell.get('position'), cell.get('size'), cell.get('angle'))
}
})科齐·大卫·杜尔曼本人就是https://groups.google.com/forum/#!topic/jointjs/cWJAK9gSC-Q
在图上,您可以发出一个事件。
graph.on('change:source change:target', function(link) {
you can use link.remove()
}发布于 2017-02-22 22:25:18
graph.getCell(linkId)不做你想做的事吗?
例如
graph.removeCells(graph.getCell(linkId))https://stackoverflow.com/questions/42313932
复制相似问题