简体   繁体   English

Angular 2:SVG 中的 ng-container

[英]Angular 2: ng-container in SVG

I have a Component with a template that consists of SVG elements.我有一个带有由 SVG 元素组成的模板的组件。 Those elements should be conditionally be rendered with *ngIf .这些元素应该有条件地用*ngIf呈现。 But because ng-container is not a valid SVG element, it can't be used.但是因为ng-container不是有效的 SVG 元素,所以不能使用。 So I used the SVG group element (g).所以我使用了 SVG 组元素 (g)。 The advantage of ng-container is that it does not appear in the DOM. ng-container的优点是它不会出现在 DOM 中。 But g -elements do appear in the DOM and so the DOM gets polluted.但是g元素确实出现在 DOM 中,因此 DOM 被污染了。 Is there a work-around?有解决办法吗?

Thx for your help!谢谢你的帮助!

您必须使用<svg:svg></svg>而不是<svg></svg>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM