我有一个包含
如何在
<linearGradient>
的<symbol>
svg精灵。我在同一<symbol>
中使用fill="url(#id)"
来填充这个渐变色到<g>
中。但是,当我在其他文档中使用<use>
加载<symbol>
时,<linearGradient>
无法加载。我可以看到填充的url引用了绝对路径而不是文档内部,因此不能正确加载。如何在
<symbol>
中加载<linearGradient>
?<symbol viewBox="0 0 550 90" width="100%" height="100%">
<defs>
<linearGradient id="gradient">
<stop offset="-1.04974" stop-color="#D8D8D8">
<animate attributeName="offset" values="-2; 1" dur="1s" repeatCount="indefinite"></animate>
</stop>
<stop offset="-0.549739" stop-color="#EEEEEE">
<animate attributeName="offset" values="-1.5; 1.5" dur="1s" repeatCount="indefinite"></animate>
</stop>
<stop offset="-0.0497395" stop-color="#D8D8D8">
<animate attributeName="offset" values="-1; 2" dur="1s" repeatCount="indefinite"></animate>
</stop>
</linearGradient>
</defs>
<g fill="url(#gradient)">
<rect x="0" y="0" width="100" height="15"/>
<rect x="10" y="25" width="130" height="15" />
</g>
</symbol>