我目前在本地计算机上而不是服务器上运行的html页面上使用svg。图像不显示:
<svg aria-hidden="true" class="slds-icon slds-icon-standard-lead slds-icon--small">
<use xlink:href="SLDS202/assets/icons/standard-sprite/svg/symbols.svg#lead"></use>
</svg>
道路是正确的。在本地计算机上,我的印象是我们无法运行使用部件。是对的吗?在服务器上并在本地计算机上,我没有发现任何限制。
这段代码在local上运行良好:
<svg version="1.1" baseProfile="full" width="300" height="200" xmlns="http://www.w3.org/2000/svg">
<rect width="100%" height="100%" fill="red" />
<circle cx="150" cy="100" r="80" fill="green" />
<text x="150" y="125" font-size="60" text-anchor="middle" fill="white">SVG</text>
</svg>
检查控制台时,出现此错误:
Unsafe attempt to load URL file:///C:/work/References/SLDS/SLDS202/assets/icons/utility-sprite/svg/symbols.svg#filterList from frame with URL file:///C:/work/References/SLDS/axa-hk-gi-demo.html.
'file:' URLs are treated as unique security origins.
引用@RobertLongson的评论,这应该是一个答案:
如果您使用的是Chrome浏览器,则其安全模型会阻止本地文件引用其他目录中的其他文件。Firefox的安全模型允许本地文件引用其他本地文件,前提是所引用的文件位于引用者的相同目录或子目录中。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句