让Polymer元素出现在JSBin中

时间:2016-08-30 07:28:48

标签: javascript polymer jsbin

我有以下代码:

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">

  <base href="http://polygit.org/polymer+:master/components/">

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

  <link rel="import" href="paper-input/paper-input.html">
  <link rel="import" href="paper-dialog/paper-dialog.html">

  <title>JS Bin</title>
</head>
<body>

       <paper-input name="some"></paper-input>
          <paper-input name="some"></paper-input>

    <my-el></my-el>

    <dom-module id="my-el">
      <template>
        <style>
          display: block;
        </style>
         I AM HERE!

          <paper-input name="some"></paper-input>
          <paper-input name="some"></paper-input>

        <script>
          Polymer({
            is: "my-el",

            ready: function(){
              console.log("READY!?!");
            }
          })
        </script>
      </template>
    </dom-module>

    AND:

  </body>
</html>

这是在Jsbin:http://jsbin.com/qiyohaj/edit?html,console,output

非常简单的问题为什么地球上不会显示“x-el”,也不会运行ready() ......?

1 个答案:

答案 0 :(得分:1)

您在模板标记内创建了脚本部分,该元素永远不会被注册。

尝试替换为:

<dom-module id="my-el">
  <template>
    <style>
      display: block;
    </style>

    <paper-input name="some"></paper-input>
    <paper-input name="some"></paper-input>
  </template>
  <script>
    Polymer({
      is: "my-el",
      ready: function(){
        console.log("ready");
      }
    });
  </script>
</dom-module>