I've been a massive fan of SVG since my days creating charts and animations with the Dojo Toolkit. SVG has been around forever, it even has IE support now, and it's ultra-flexible. When creating this site's redesign, I used SVG within an IMG tag and it work great locally. When I pushed to the live server, however, the image displayed as broken and I saw the following notice in the console:
自从使用Dojo Toolkit创建图表和动画以来,我一直是SVG的忠实拥护者 。 SVG已经存在了很长时间,甚至现在都支持IE,而且它非常灵活。 在创建该网站的重新设计时,我在IMG标签中使用了SVG,并且在本地效果很好。 但是,当我推送到实时服务器时,该图像显示为损坏,并且在控制台中看到以下通知:
Resource interpreted as Image but transferred with MIME type text/xml: "https://davidwalsh.name/logo.svg".
That was certainly unexpected. Obviously there was a difference in my local server and my production server, so after a bit of research, I found that the following .htaccess update would resolve the issue:
这当然是出乎意料的。 显然,本地服务器和生产服务器之间存在差异,因此,经过一些研究,我发现以下.htaccess更新将解决此问题:
AddType image/svg+xml svg svgz
AddEncoding gzip svgz
Serving SVG as XML, what it essentially is, really isn't of use to me -- I want to use it in its visual glory. Keep this snippet handy in case you also run into this issue!
SVG作为XML的本质,实际上对我没有用-我想在视觉上使用它。 请妥善保存此代码段,以防您也遇到此问题!