我可以在html页面中放置多个svgs并在所有这些页面中使用相同的ID吗?
<div> <svg height="0" width="0"> <clipPath id="svgPath"> ........ </svg> <svg height="0" width="0"> <clipPath id="svgPath"> ........ </svg> <svg height="0" width="0"> <clipPath id="svgPath"> ........ </svg> </div>
解决方法
由于规范将id属性定义为每个文档唯一,因此您应该重构ID或使用替代方法,例如通过img或object标签嵌入.
<img src="my.svg" height="100" alt="alternative Text"> <object type="image/svg+xml" data="my.svg" width="100" height="100"></object>