0

我需要动态更改 svg 中 foreignObject 的高度。我必须使用foreignObject,因为我需要其中的html元素。(我正在使用 ngx-graph)。

<foreignObject x="1" y="1" width="335" [height]="foreignObjHeight(node.Data.length)" class="{{ checkIfSourceNode(node) }}"> ...

我收到错误:

TypeError:无法设置只有 getter 的 [object SVGForeignObjectElement] 的属性高度

请帮忙!

4

1 回答 1

0

在您的情况下,您可以将 height 属性设置为其值:

<foreignObject x="1" y="1" width="335" [attr.height]="foreignObjHeight(node.Data.length)" ">
于 2022-02-16T12:35:49.633 回答