【发布时间】:2012-07-15 21:17:53
【问题描述】:
Chrome 似乎没有在内联 svg 中显示 <use> 元素。这是一个示例(下面的代码或在http://www.bobwyttenbach.com/chromeuse.html查看):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Chrome use-tag bug?</title>
</head>
<body>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="200px" height="200px" viewBox="0 0 200 200">
<defs>
<g id="test1">
<circle cx="100" cy="100" r="50" fill="red"/>
</g>
</defs>
<g>
<rect x="0.5" y="0.5" width="199" height="199" stroke="black" fill="none"/>
<use xlink:href="#test1" x="0" y="0"/>
</g>
</svg>
<p>Above is inline svg with a use tag; below is the same svg linked through an object tag. Below is correct.</p>
<object data="chromeuse.svg" width="200" height="200"></object>
</body>
</html>
红色圆圈不会出现在内联 svg 中,但会在同一个 svg 通过对象标签链接时出现。 Safari、Firefox、Opera 和 Internet Explorer 9 都能正确显示内联 svg。
我做错了吗?这是一个已知的 Chrome 错误吗(我没有找到它列出)?有什么解决方法吗?
【问题讨论】:
-
听起来像一个错误,在这里向 webkit 报告:bugs.webkit.org
-
这就是我从 chromium@googlecode.com 得到的回复:pdr@chromium.org 对问题 137666 的评论 #2:Chrome 中未显示 SVG
-
更新:在当前版本的 Chrome (21.0.1180.57) 中修复,该版本使用 WebKit 537.1。在昨天的 Safari (6) 版本中新破解,它使用 WebKit 536.25。
-
Chrome 36.0.1985.143版本问题依然存在。这个问题有其他解决方案吗?
-
现在显然这是一个安全“功能”。
标签: google-chrome svg