这是我获取返回对象的代码,但是我无法打开要打开的对象并查看其中的内容
var connections = [];
$.each(instance.getAllConnections(), function (idx, connection) {
connections.push({
connectionId: connection.id,
pageSourceId: connection.sourceId,
pageTargetId: connection.targetId,
anchors: $.map(connection.endpoints, function(endpoint) {
return [[endpoint.anchor.x,
endpoint.anchor.y,
endpoint.anchor.getOrientation()[0],
endpoint.anchor.getOrientation()[1],
endpoint.anchor.offsets[0],
endpoint.anchor.offsets[1]
]];
})
});
console.log(util.inspect(connections.endpoints));
});
// console.log(connections);
console.log(util.inspect(connections));
这就是我在物体中得到的东西
答案 0 :(得分:0)
我通过这样做得到了物体
var connections = [];
$.each(instance.getAllConnections(), function (idx, connection) {
connections.push({
connectionId: connection.id,
pageSourceId: connection.sourceId,
pageTargetId: connection.targetId,
arrowendpoint1:connection.endpoints[0].anchor.x,
arrowendpoint2:connection.endpoints[0].anchor.y,
arrownendpoint3:connection.endpoints[1].anchor.x,
arrownendpoint4:connection.endpoints[1].anchor.y,
// anchors: $.map(connection.endpoints, function(endpoint) {
// return [[endpoint.anchor.x,
// endpoint.anchor.y,
// endpoint.anchor.getOrientation()[0],
// endpoint.anchor.getOrientation()[1],
// endpoint.anchor.offsets[0],
// endpoint.anchor.offsets[1]
// ]];
// })
});
});
console.log(util.inspect(connections));