Chrome 似乎不会<use>
在内联 svg 中显示元素。这是一个示例(下面的代码或在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 错误吗(我没有找到它列出)?任何解决方法?