Polymer Simple Component Not working - Everything is loaded but No Shawdow Root, No Error

时间:2015-06-30 13:56:45

标签: javascript html5 polymer-1.0

I am trying out polymer and could not make it to work a simple component. Based on the docs. I have done the following thing

Added webcomponents.js, imported polymer.html and created a simple helloworld component without any script. I can see everyhting loaded in the DEV tools but the shawdow root is not created in helloworld components.

Polymer version is "polymer": "Polymer/polymer#~1.0.5"

Below is the hello world code.

<polymer-element name="hello-world" noscript>
  <template>
    <h1>Hello World</h1>
  </template>
</polymer-element>

Webcomponentjs with 200

Polymer and helloworld components loaded

But no shawdow root in helloworld.enter image description here

What am I doing wrong here.

1 个答案:

答案 0 :(得分:1)

您使用的是Polymer v1.0,但您似乎没有按照此版本的方式声明您的元素。见here

<dom-module id="hello-world">
  <style>
    /* CSS rules for your element */
  </style>

  <template>
    <!-- local DOM for your element -->

    <h1>Hello world</h1>
  </template>

  <script>
    // element registration
    Polymer({
      is: "hello-world"
    });
  </script>
</dom-module>