How many levels of recursion does SVG support?(SVG支持多少级别的递归?)
转载作者:bug小助手更新时间:2023-10-25 14:08:19254
I cannot get past 2 levels. (Tried on Iceweasel and Chromium.)
我不能超过2级。(在冰鼠狼和铬上试过了。)
As a test, I tried a variant of the code presented in this earlier reply. This one consists of 3 separate files, where a.svg includes b.svg, and b.svg includes c.svg. (NB:This is not a cycle.)
I expected to see a large dark yellow dot, a medium-sized orange dot, and a small red dot, but I see only the first two. In fact, what I see is exactly the same as what I would see if b.svg did not include c.svg.
Is there a way to get SVG recursion to work for more than 2 levels?
有没有办法让SVG递归在两个以上的级别上工作?
更多回答
I've uploaded the test files above to a.svg, b.svg, c.svg, with the addition of colored rectangles behind each image (to show where they should be). You can use the Developer Tools of Chrome to show that c.svg never attempts to load.
If you post your use case you may get some very good recommendations on how to achieve what you're looking for. For example, you can have <svg>s inside other <svg>s and can manipulate this DOM with Javascript.
如果你发布你的用例,你可能会得到一些关于如何实现你想要的东西的非常好的建议。例如,您可以将
优秀答案推荐
SVG when used as an image must be complete in a single file.
当SVG用作图像时,必须在单个文件中完成。
a.svg is not an image
b.svg is included as an image by a.svg and is therefore subject to the complete in a single file image rule so any images it contains must be included as data URIs.
c.svg is ignored as b.svg cannot refer to external files.
Convert c.svg to a data URI and include it inline in b.svg to get round this.
将c.svg转换为数据URI并将其内联包含在b.svg中以解决此问题。
更多回答
This is very good to know. Your profile leads me to think you may know a thing or two about this :)
我是一名优秀的程序员,十分优秀!