gojs addNodeData函数不会将节点添加到图中

时间:2019-12-01 13:09:30

标签: gojs

我的代码:

 diagram.nodeTemplate = this.getNodeTemplate();
 // ...
 let node1 =this.from;
 node1.key = id + "_0";
 node1.side = "left";
 node1.group = id;
 let node2 = this.to;
 node2.key = id + "_1";
 node2.side = "right";
 node2.group = id;
 diagram.startTransaction("new group");
 let groupNode = { key: id, isGroup: true, details: this };
 diagram.model.addNodeData(groupNode);
 diagram.commitTransaction("new group");
 diagram.startTransaction("new data");
 diagram.model.addNodeData(node1);
 diagram.model.addNodeData(node2);
 diagram.model.addLinkData({ from: node1.key, to: node2.key, fromPort: this.from.port.InvPortName, toPort: this.to.port.InvPortName, operation: this.operation });
diagram.commitTransaction("new data");

node2已添加到图中。 将node1添加到diagram.model.nodeDataArray,但未在图中显示,并且getNodeTemplate函数不执行。

0 个答案:

没有答案