【问题标题】:How to add image to SVG with Bobril如何使用 Bobril 将图像添加到 SVG
【发布时间】:2017-06-29 22:56:01
【问题描述】:

我正在尝试使用 Bobril 将图像添加到 SVG,但此代码不起作用:

{
    tag: 'svg',
    children: {
        tag: 'image',
        attrs: {
            'xlink:href': 'https://raw.githubusercontent.com/Bobris/Bobril/master/logo.png',
            x: 0,
            y: 0,
            width: 200,
            height: 200
        }
    }
}

图像标签被添加到页面,但没有显示图像。当我在 Chrome 的 DevTools 中复制元素并再次粘贴时,会显示图像。我究竟做错了什么?

【问题讨论】:

    标签: javascript image typescript svg bobril


    【解决方案1】:

    只使用 href 而不是 'xlink:href'。

    xlink:href 自 SVG 2 起已弃用

    【讨论】:

    猜你喜欢
    • 2021-04-09
    • 1970-01-01
    • 2015-04-14
    • 1970-01-01
    • 1970-01-01
    • 2013-01-12
    • 2017-02-20
    • 2017-02-13
    • 2017-01-14
    相关资源
    最近更新 更多