Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/svg/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在SVG中使用外部def将标识符注入includer';s范围_Svg - Fatal编程技术网

如何在SVG中使用外部def将标识符注入includer';s范围

如何在SVG中使用外部def将标识符注入includer';s范围,svg,Svg,我有这样一个工作的main.svg文件: <?xml version="1.0" encoding="UTF-8" ?> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <defs id ="mydefs"> <marker id="markerEnd" markerWidth="15" markerHeight="15" re

我有这样一个工作的main.svg文件:

<?xml version="1.0" encoding="UTF-8" ?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<defs id ="mydefs">
    <marker id="markerEnd" markerWidth="15" markerHeight="15" refX="7" refY="7" orient="auto">
        <path d="M0,0 l7,7 l-7,7" style="stroke: #000000;fill: none;"/>
    </marker>
</defs>
    <line x1="0" y1="0" x2="200" y2="200" stroke="black" marker-end="url(#markerEnd)"/>
</svg>
我知道Google Chrome中本地文件的跨源策略,但这不是问题所在,我在许多其他浏览器上进行了测试

如果需要HTML来测试SVG:

<!DOCTYPE html>
<html>
<head>
<style>
html, body, object {
  width: 100%;
  height: 100%;
}
</style>
<body>
<object type="image/svg+xml" data="main.svg"></object>
</body>
</html>

html、正文、对象{
宽度:100%;
身高:100%;
}
有这样一个问题:
但是从这些答案中,我无法理解如何解决这个问题。

SVG不是这样工作的<代码> >与C++或java包含语句不一样,它只是渲染标记子集的一种方式。谢谢。如果是这样,我想知道如何将def注入SVG范围的变通方法:1)使用JavaScript注入(我目前的解决方案,我不喜欢).3)还有什么?你最后是怎么做的?我面临着完全相同的需求,但需要引用过滤器。谢谢!不幸的是,我还没有解决它。这个问题的优先级很低,我们推迟了。似乎其他人对这个话题不感兴趣。
<?xml version="1.0" encoding="UTF-8" ?>
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
    <defs>
        <use xlink:href="defs.svg#mydefs" />
    </defs>
    <use xlink:href="defs.svg#mydefs" />
    <line x1="0" y1="0" x2="200" y2="200" stroke="black" marker-end="url(#markerEnd)"/>
</svg>
<!DOCTYPE html>
<html>
<head>
<style>
html, body, object {
  width: 100%;
  height: 100%;
}
</style>
<body>
<object type="image/svg+xml" data="main.svg"></object>
</body>
</html>