我试图像这样动态设置svg图像的href:
<svg style="width:100%; height:100%">
<image x="-29" y="7" height="53" width="170" xlink:href="{{logoFile}}" />
</svg>
Run Code Online (Sandbox Code Playgroud)
但是然后我在控制台中出错:无法绑定到':xlink:href',因为它不是':svg:image的已知属性
由于xlink:href是SVG 图像元素的属性而不是属性,因此请使用属性绑定:
[attr.xlink:href]="logoFile"
Run Code Online (Sandbox Code Playgroud)
有关演示,请参见此堆叠闪电战。