当前位置: 动力学知识库 > 问答 > 编程问答 >

snap.svg - load compressed svg with Snap SVG

问题描述:

I have:

Snap.load(src, function(f){im = canvas.canvasSvg.g(f.select('*'));});

Where the variable src holds a direction to a svg file (as in: "resources/foo.svg").

I need to place the loaded svg in a group to access it properly later on. This works perfectly fine.

Now, I'd like to use compressed svg format (svgz). But when src points to a svgz file, ("resources/foo.svgz"), I get the following error:

Resource interpreted as Image but transferred with MIME type application/x-gzip: "http://localhost:8888/web/resources/foo.svgz".

Why is this? And how can I load the compressed foo.svgz into Snap? Thanks!

网友答案:

If this file is coming from a web server, you need to leave the mime-type alone i.e. keep it as image/svg+xml and instead change the Content-Encoding to gzip

If it's a local file you're out of luck as there's no way to indicate to the UA what it is unless the UA natively recognises it and most don't.

分享给朋友:
您可能感兴趣的文章:
随机阅读: