HTML导入WebComponents Polyfill在Firefox中不起作用 [英] HTML Import webcomponents polyfill not working in firefox

查看:278
本文介绍了HTML导入WebComponents Polyfill在Firefox中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在示例应用程序中使用Webcomponents.由于某些规格未包含在某些浏览器中,因此我尝试使用polyfill.在Mozilla firefox中,我尝试通过启用键dom.webcomponents.enabled并添加一些polyfill(不在浏览器中)来进行尝试.我已经使用了从webcomponents.js polyfill的HTML Import polyfill.

I am trying webcomponents in a sample app. Since some of the specs are not included in some browsers, i tried using polyfill for those. In Mozilla firefox, i tried by enabling the key dom.webcomponents.enabled and adding some polyfills (that are not in browser). I have used HTML Import polyfill from webcomponents.js polyfill.

仍然HTMLImport不能在Internet Explorer的Firefox(即使使用polyfill)中工作. ( https://github.com/webcomponents/webcomponentsjs )

Still HTMLImport is not working in firefox, internet explorer (even with polyfill). (https://github.com/webcomponents/webcomponentsjs)

我还尝试了customElements v1 polyfill,但无法在Internet Explorer和Firefox中使用. ( https://github.com/webcomponents/custom-elements )

I also tried customElements v1 polyfill, not working in internet explorer and firefox. (https://github.com/webcomponents/custom-elements)

有人成功将HTMLimports polyfill与customElements V1 polyfill包括在内吗?

Has anybody succeeded in including HTMLimports polyfill with customElements V1 polyfill?

推荐答案

要在Firefox中使用带有HTML导入的自定义元素v1:

To use, in Firefox, Custom Elements v1 with HTML Imports:

  1. 请勿不要激活Firefox标志,因为该实现已过时.
  2. 安装 webcomponentsjs (例如,以凉亭方式),并且仅在主文件中包含htmlimports.min.js文件.
  3. 安装自定义元素(通过链接),并将其包含在主文件custom-elements.min.js中.
  1. Do not activate Firefox flags as the implementation is outdated.
  2. Install webcomponentsjs (with bower for example), and include in your main file only htmlimports.min.js file.
  3. Install custom-elements (from your link) and include in your main file custom-elements.min.js.

您的主页应如下所示:

<head>
   <script src="htmlimports.min.js"></script>
   <script src="custom-elements.min.js"></script>
   <link rel="import" href="your-components.html">
</head>
<body>
    <your-component></your-component>

NB:对于第3步,您还可以使用 document-注册元素.

NB: for step 3, you can also use document-register-element.

由于未实现class,因此不能直接在Internet Explorer中使用自定义元素v1 class"语法.您首先需要使用像Babel这样的编译器来转换源代码.

You cannot use Custom Elements v1 class syntax with Internet Explorer directly because class is not implemented. You'll need first to transform the source code with a transpiler like Babel.

或者,使用现代版本(Edge),或使用prototype语法.

Alternately, use a modern version (Edge), or use the prototype syntax.

这篇关于HTML导入WebComponents Polyfill在Firefox中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆