【问题标题】:Polymer element not showing in firefox聚合物元素未在 Firefox 中显示
【发布时间】:2014-09-09 16:02:36
【问题描述】:

我编写了在 Chrome 中完美运行的自定义聚合物元素。但它甚至没有出现在 Firefox 中。我使用 vulcanize 将所有内容连接到一个文件中,甚至是平台和聚合物。这是我调用 vulcanize 的主索引文件。

<!DOCTYPE html>
<html>
 <head>
  <script src="bower_components/platform/platform.js"></script>
  <link rel="import" href="bower_components/my_polymer/index.html">
 </head>
</html>

这是我的聚合物元素索引文件。

<!DOCTYPE html>
 <html>
  <head>
   <link rel="import" href="../polymer/polymer.html">
   <link rel="import" href="my-polymer-element.html">
  </head>
 </html>

【问题讨论】:

  • 我在 Firefox 中也遇到了 Polymer 的问题。你检查错误控制台了吗?
  • Chrome 中没有警告或错误,但在 Firefox 中我收到了此警告。改变对象的 [[Prototype]] 会导致您的代码运行非常缓慢;而是使用 Object.create 创建具有正确初始 [[Prototype]] 值的对象
  • 我不确定这个错误是不是因为 Firefox 不支持,因为我什至在 Firefox 版本 31 中看不到这个页面 polymer-project.org/components/core-elements/demo.html,但至少它在控制台中显示错误。

标签: javascript firefox polymer web-component


【解决方案1】:

您的设置有误。

您不应该导入 index.html,而是在主页中导入您的元素定义。您的主页应如下所示:

<html>
  <head>
   <script src="bower_components/platform/platform.js"></script>
   <link rel="import" href="my-polymer-element.html">
  </head>
  ...
</html>

请注意,polymer.html 在您的 my-polymer-element.html 定义文件的顶部列为依赖项导入。

有关示例,请参见 http://www.polymer-project.org/docs/start/creatingelements.html#createpolyel 以及种子元素:http://www.polymer-project.org/docs/start/reusableelements.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多