1

我正在尝试制作一个简单的“Hello World!” 元素。我已经尝试使用 bower 安装聚合物组件,并且我使用了 zip 文件。我也使用了 python 和 npm HTTP 服务器,但我仍然没有得到任何输出。 <html> <head> <title>Polymer</title> <script src="bower_components/webcomponentsjs/webcomponents-lite.min.js"></script> <link rel="import" href="elements/hello-world.html"> </head> <body unresolved> <hello-world></hello-world> </body> </html>

与元素文件 <link rel="import" href="../bower_components/polymer/polymer-mini.html"> <polymer-element name="hello-world" noscript> <template> <h1>Hello World!</h1> </template> </polymer-element>

4

1 回答 1

7

您为聚合物元素使用了错误的 API。你应该使用<dom-module>像 Trevor Dixon 提到的那样。

见 Plunker

<link rel="import" href="../bower_components/polymer/polymer-mini.html">

<dom-module id="hello-world">
    <template>
    <h1>Hello World!</h1>
    </template>
</dom-module>

<script>
Polymer({
  is: 'hello-world'
})
</script>
于 2015-06-05T06:33:38.960 回答