无法获得其他功能的特定值

时间:2019-06-07 16:29:54

标签: javascript gojs

我正在努力使用Gates制作逻辑电路,并使用javascript和GoJS制作多路复用器。我想获取一个特定的输入端口值,并在另一个函数中使用它

      var multiplexarTemplate =
      $(go.Node, "Spot", nodeStyle(),
      $(go.Shape, "Rectangle",  { width: 50, height: 80, margin: 4, 
      fill: "lightgray",  stroke: "darkslategray", strokeWidth: 2 
      }), 
      $(go.Shape, "Rectangle", portStyle(true),
        { portId: "in1", alignment: new go.Spot(0, 0.2) }),
      $(go.Shape, "Rectangle", portStyle(true),
        { portId: "in2", alignment: new go.Spot(0, 0.4) }),
      $(go.Shape, "Rectangle", portStyle(true),
        { portId: "in3", alignment: new go.Spot(0, 0.6) }),  
      $(go.Shape, "Rectangle", portStyle(true),
        { portId: "in4", alignment: new go.Spot(0, 0.8) }),
      $(go.Shape, "Rectangle", portStyle(true),
        { portId: "in5", alignment: new go.Spot(0.3, 1) }),
      $(go.Shape, "Rectangle", portStyle(true),
        { portId: "in6", alignment: new go.Spot(0.65, 1) }),
        $(go.Shape, "Rectangle", portStyle(false),
        { portId: "out", alignment: new go.Spot(1, 0.5) }) 
       )

在此示例中,我想特别获取in1并将其用于另一个函数中。以同样的方式,我也想获取in2,in3,in4并将其用于其他功能,但是我不知道该怎么做。

1 个答案:

答案 0 :(得分:0)

使用Node.findPorthttps://gojs.net/latest/api/symbols/Node.html#findPort

var in2 = someNode.findPort('in2');