【问题标题】:Picturefill in IE11 with Vue.js用 Vue.js 在 IE11 中填充图片
【发布时间】:2017-06-16 15:45:44
【问题描述】:

在 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 认为它​​是一个自定义标签?

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

【问题讨论】:

  • 其他浏览器也一样:chrome/firefox?
  • 它适用于其他浏览器,只是不适用于 IE11 和可能的旧版本。因为它无法识别图片元素。

标签: javascript internet-explorer vue.js picturefill


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-19
    • 2015-04-22
    • 2023-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-19
    • 1970-01-01
    相关资源
    最近更新 更多