模型端口的 JointJS 2.2.1 样式

JointJS 2.2.1 styling for Model's port

之前我使用的是 JointJS 0.9.10,shapes.devs.Model 的属性正常工作,如下所示

attrs: {
      '.inPorts .port-body': { fill: 'red' },
      '.outPorts .port-body': { fill: 'yellow' }
}

但是当我将 JointJS 升级到 2.2.1 版本时,此样式不再影响模型的端口。这个 属性 名称是否在最新版本中得到了更改。哪位知道这个问题的请给我解释一下,谢谢

JointJS v2.2.1 中的等效表达式如下所示。

el.prop({
  ports: {
    groups: {
      'in': {
        attrs: {
          '.port-body': { fill: 'red' }
        }
      },
      'out': {
        attrs: {
          '.port-body': { fill: 'yellow' }
        }
      }
    }
  }
});

从版本 1.0 开始,可以向任意 joint.dia.Element 添加端口。端口不是元素标记的一部分,不能再通过 attrs 设置样式。

有关详细信息,请参阅端口 API documentation