gpt4 book ai didi

html - Chrome 在 中加载 SVG 时发出警告

转载 作者:太空宇宙 更新时间:2023-11-03 19:00:42 25 4
gpt4 key购买 nike

为了在 Canvas 上显示 SVG 图像文件,我在 HTML 中添加了以下行:

<img id="soundOnImg" src="img/speaker_on.svg" style="display:none"></img>

然后在 Canvas 上绘制它:

ctx2d.drawImage($("#soundOnImg")[0], 10, 10, 200, 200);

(在那里使用 jQuery $())

除了一个烦人的地方外,这一切都很好——Chrome 给我以下警告:

Resource interpreted as image but transferred with MIME type image/svg+xml.

这个警告是什么意思?

我尝试使用 <object>而不是 <img>但这失败了,因为对象元素似乎没有 [0]出于某种原因。

我该如何解决这个问题?

最佳答案

这是与 Chrome 捆绑在一起的 WebKit 代码中的错误。 WebInspector.Resource._checkWarning()电话 WebInspector.Resource._mimeTypeIsConsistentWithType()检查资源的 mime 类型。此函数根据 WebInspector.MIMETypes 检查值对象,它不包含 SVG 图像的条目。

这似乎没有在 WebKit trunk 中修复,所以你可能应该 report it as a bug .

关于html - Chrome 在 <img> 中加载 SVG 时发出警告,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12132160/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com