【发布时间】:2018-07-06 13:39:13
【问题描述】:
我已将 base64encodeed 图像加载到 'xlink:href' 属性,用于 #patternImage 图像标签。它在 Chrome 和 Firefox 中运行良好,但在 Safari 中无法运行。
HTML:
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id='svgId' width="576" height="720" style="outline:auto;" >
<defs>
<pattern id="imgpattern" x="0" y="0" width="20" height="20" patternUnits="userSpaceOnUse">
<image id="patternImage" xlink:href="" width="20" height="20"></image>
</pattern>
</defs>
<path id="svgpath" stroke="#f000" fill="#ff0000" stroke-width="0.25px" style="fill:url(#imgpattern) !important"></path>
</svg>
JS:
$("#patternImage").attr("xlink:href",encodedImage);
$("#patternImage").load(function(){
console.log("Loaded");
});
【问题讨论】:
-
请再给我们看几行您的“HTML”。你如何使用
<image>?作为<pattern>的一部分?另外,您加载的图像是什么 mimetype?如果是 SVG,也请以未编码的形式显示。 -
@ccprog
<image>是<pattern>的一部分 -
哪个版本的 Safari?在 11.1.1 jsfiddle.net/2q93wu15/1 上为我工作此外,我正在加入 @ccprog 请求 minimal reproducible example。我们需要知道设置的图像是什么,
d的实际路径是什么。 -
@ Kaiido其还11.1.1和路径
dID动态像“d =“M 0,0大号252144 612144 612180 648180 648216 684216 684252 720252 720612 684612 684648 648648 648684 612684 612720 252720 252684 216684 216,648 180,648 180,612 144,612 144,252 180,252 180,216 216,216 216,180 252,180 252,144 0,0 L 0,0 0,864 864,864 864,0 0,0" -
我们需要知道设置的图像是什么。即使有这个
d属性it still works for me。你能确认它不适合你吗?
标签: javascript svg xlink