svg - Inkscape 忽略 <use>

标签 svg inkscape

在 Inkscape 中导入以下 SVG 文件仅显示文本但忽略 <use>语句(或它引用的组)。这是错误还是功能?有什么要改变的吗?顺便说一句,<g>组比示例文件中的组更复杂。该文件在 Chrome 中正确显示。 (Windows 10,Inkscape 最新版本)

谢谢! 马里奥

<svg width="400" height="200" x="0" y="0"
    xmlns="http://www.w3.org/2000/svg">
<defs>
  <g id="plus">
    <circle cx="40" cy="30" r="20" stroke="#FF0000" fill="none"></circle>
  </g>
</defs>
<svg x="100" y="50">
  <rect x="1" y="1" width="78" height="86" rx="10" ry="10" stroke="#0000FF" fill="none"></rect>
  <use href="#plus"></use>
  <text x="20" y="74" width="68" height="26">ABCD</text>
</svg>
</svg>

最佳答案

<use href="#plus">应该是 <use xlink:href="#plus"> .另外,您需要添加 xmlns:xlink属性到您的根 SVG 标签。

<svg width="400" height="200" x="0" y="0"
    xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs>
  <g id="plus">
    <circle cx="40" cy="30" r="20" stroke="#FF0000" fill="none"></circle>
  </g>
</defs>
<svg x="100" y="50">
  <rect x="1" y="1" width="78" height="86" rx="10" ry="10" stroke="#0000FF" fill="none"></rect>
  <use xlink:href="#plus"></use>
  <text x="20" y="74" width="68" height="26">ABCD</text>
</svg>
</svg>

如果您进行了这些修复,文件将加载到 Inkscape 中。

关于svg - Inkscape 忽略 <use>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56061765/

相关文章:

command-line - 通过命令行(inkscape)更改 svg 文件中的颜色

带滤镜的 SVG 图像 - 滤镜覆盖的区域大于图像

javascript - 创建后获取 d3.js SVG 文本元素的宽度

google-chrome - 如何摆脱 SVG 中不需要的细边框?不同的行为(IE、Chrome 等)

python - 有没有一种有效的方法可以在 python 中将 2D 图存储为矢量图形?

python - Inkscape 扩展不起作用

javascript - 使用 jQuery 将 SVG 元素插入到 HTML 标记中

javascript - 如何缩放 SVG 以使其中绘制的内容适合容器大小?

html - 可以在 SVG 中将 &lt;!-- comment --> 作为第一行吗?

image - Inkscape - 未完全将 png 转换为 svg