IE11 中的图片填充 Vue.js

Picturefill in IE11 with Vue.js

在 IE11 中,Picturefill 库不适用于 Vue.js。我收到以下警告:

[Vue warn]: Unknown custom element: <picture> - did you register the component correctly? For recursive components, make sure to provide the "name" option.

我可以使用 Vue.config.ignoredElements = ['picture'] 删除警告,但这似乎无法解决问题。我认为在幕后 Vue.js 正在使用图片标签做事,因为它不能被 IE11 识别,因此 Vue.js 认为它是一个自定义标签?

请告诉我如何解决这个问题!谢谢

对于IE11,你必须在DOM中加载图片标签后调用picturefill函数。它会动态添加src属性到img标签。

//For IE 11 Fix
    if(typeof picturefill === "function") {
      picturefill();
    }