【问题标题】:Can't bind to ':xlink:href' since it isn't a known property of ':svg:image'不能绑定到 ':xlink:href' 因为它不是 ':svg:image' 的已知属性
【发布时间】:2023-04-03 08:28:01
【问题描述】:

我正在尝试像这样为 svg 图像动态设置 href:

<svg style="width:100%; height:100%">
    <image x="-29" y="7" height="53" width="170" xlink:href="{{logoFile}}"  />
</svg>

但后来我在控制台中遇到错误: 无法绑定到 ':xlink:href',因为它不是 ':svg:image 的已知属性

【问题讨论】:

    标签: angular svg


    【解决方案1】:

    由于 xlink:href 是 SVG image 元素的属性而非属性,请使用 attribute binding

    [attr.xlink:href]="logoFile"
    

    请参阅this stackblitz 以获取演示。

    【讨论】:

    猜你喜欢
    • 2017-10-29
    • 2017-10-15
    • 2022-08-22
    • 2022-11-10
    • 2017-04-04
    • 2018-11-30
    • 1970-01-01
    • 2022-11-08
    • 2017-02-03
    相关资源
    最近更新 更多