移动节点后如何获取当前位置以保存到数据库新位置。
myDiagram.addDigramListener("SelectionMoved",
function(e) {
let part = e.subject.part;
console.log(part)
}
)
但部分总是为空,为什么?
e.subject
是一个集合,它是所有移动部件的选择。移动的部件可能不止一个。
如果你有理由确定只有一个 Part 被移动,你可以写:
myDiagram.addDigramListener("SelectionMoved",
function(e) {
let part = e.subject.first();
console.log(part.toString())
}
)
但是如果你只是想把位置保存到数据库中,为什么不在位置上做一个双向数据绑定呢?的流程图实例说明了这一点:
// The Node.location comes from the "loc" property of the node data,
// converted by the Point.parse static method.
// If the Node.location is changed, it updates the "loc" property of the node data,
// converting back using the Point.stringify static method.
new go.Binding("location", "loc", go.Point.parse).makeTwoWay(go.Point.stringify),
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句