聚合物示例代码在Firefox中不起作用

编程入门 行业动态 更新时间:2024-10-26 20:33:15
本文介绍了聚合物示例代码在Firefox中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试Google在 https:/中提供的示例代码/www.polymer-project/1.0/start/first-element/intro .

I am trying out sample code provided by Google at www.polymer-project/1.0/start/first-element/intro.

这是我到目前为止所拥有的:

This is what I have so far:

index.html:

index.html:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"> <script src="polygit/components/webcomponentsjs/webcomponents-lite.js"></script> <link href="/my_components/icon-toggle-demo.html" rel="import"> </head> <body> <icon-toggle-demo toggle-icon="star"></icon-toggle-demo> </body> </html>

icon-toggle-demo.html:

icon-toggle-demo.html:

<link rel="import" href="polygit/components/polymer/polymer.html"> <link rel="import" href="polygit/components/iron-icons/iron-icons.html"> <link rel="import" href="icon-toggle.html"> <dom-module id="icon-toggle-demo"> <template> <style> :host { font-family: sans-serif; }; </style> <h3>Statically-configured icon-toggles</h3> <icon-toggle toggle-icon="star"></icon-toggle> <icon-toggle toggle-icon="star" pressed></icon-toggle> <h3>Data-bound icon-toggle</h3> <!-- use a computed binding to generate the message --> <div><span>[[message(isFav)]]</span></div> <!-- curly brackets ({{}}} allow two-way binding --> <icon-toggle toggle-icon="favorite" pressed="{{isFav}}"></icon-toggle> </template> <script> Polymer({ is: "icon-toggle-demo", message: function(fav) { if (fav) { return "You really like me!"; } else { return "Do you like me?"; } } }); </script> </dom-module>

icon-toggle.html:

icon-toggle.html:

<link rel="import" href="polygit/components/polymer/polymer.html"> <link rel="import" href="polygit/components/iron-icon/iron-icon.html"> <dom-module id="icon-toggle"> <template> <style> /* local DOM styles go here */ :host { display: inline-block; } iron-icon { fill: rgba(0,0,0,0); stroke: currentcolor; } :host([pressed]) iron-icon { fill: currentcolor; } </style> <!-- local DOM goes here --> <!-- <span>Not much here yet.</span> --> <!-- <iron-icon icon="polymer"> --> <iron-icon icon="[[toggleIcon]]"> </iron-icon> </template> <script> Polymer({ is: 'icon-toggle', properties: { toggleIcon: String, pressed: { type: Boolean, value: false, notify: true, reflectToAttribute: true } }, listeners: { 'tap': 'toggle' }, toggle: function() { this.pressed = !this.pressed; } }); </script> </dom-module>

代码在chrome中工作正常,但在FF中出现以下错误:

The code works fine in chrome but I get following error in FF:

TypeError: document.registerElement is not a function

我已经包含了polyfill.还有其他东西吗?

I have already included the polyfill. Something else missing?

推荐答案

您没有做错任何事情. index.html文件中的以下行默认为webcomponents polyfill的最新版本(v1.0.0-rc.1).

You're doing nothing wrong. The following line in your index.html file defaults to the newest version (v1.0.0-rc.1) of the webcomponents polyfill.

<script src="polygit/components/webcomponentsjs/webcomponents-lite.js"></script>

当前版本的Firefox中似乎存在一个错误.在Polymer文档此处中链接的Plunker中也可以观察到相同的错误. .希望这将由Polymer团队解决.

There appears to be a bug in the current version for Firefox. The same error can also be observed in the Plunker that is linked in the Polymer docs here. This will hopefully be fixed by the Polymer team.

要立即修复,可以显式使用旧版本.例如.

To fix it for now, you can explicitly use an older version. For example.

<script src="cdn.rawgit/webcomponents/webcomponentsjs/v0.7.24/webcomponents-lite.js"></script>

更多推荐

聚合物示例代码在Firefox中不起作用

本文发布于:2023-08-02 17:09:57,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1279603.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:聚合物   示例   中不   代码   Firefox

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!